Skip to content

Optimizing and Deploying your Dojo based page

peller edited this page Feb 23, 2012 · 7 revisions

To test a page, you may simply Download your workspace as a zip file, unpack it on a web server, and run. However, Dojo-based widgets used in your page are comprised of multiple Javascript modules and CSS files, so loading time for these pages, particularly over connections with high latency, will be sub-optimal. Dojo comes with tools to pack multiple Javascript and CSS files into fewer files and minify them by removing whitespace and shortening symbols. The Dojo library in your workspace is already built in such a manner, but not customized for the dependencies in your page. To optimize your page, you will need to take the following steps prior to deployment on your web server:

  1. Edit your .html file and combine all of the require() calls into one using a single array argument (see issue #1750) Duplicates may be removed (see issue #845)

  2. If you are using only dojox.mobile in your page, you may use dojox/mobile/parser in place of dojo/parser and also eliminate the dependency on dijit/dijit

  3. Download a source distribution of Dojo and copy it over the one at lib/dojo

  4. Create a build profile with the necessary dependencies for your page and run the build tool. Sitepen has a tutorial on how this is done. Here is an example for a sample1.profile to create a custom build for the Sample1.html example. To run,

    cd util/buildscripts; ./build.sh --profile /path/to/sample1.profile

This will create a dijit/sample1.js file which you would put in your require() statement, replacing the modules listed as dependencies.

When the Dojo Web Builder supports version 1.7, you may use this simple cloud-based service in place of the last 2 steps. [Q: how does it handle the existing Dojo library in the zip file?]

For Mobile applications, you may also choose to deploy your page as a PhoneGap app. Because this installs the files locally on your device, the build step is less critical, but may be required to workaround a problem with the Android build.

Clone this wiki locally