-
Notifications
You must be signed in to change notification settings - Fork 20
Dojobuild
Speed, speed and speed. Your users will be thankful! Dojo comes with a built in build system that
- shrinks your javascript files by removing unnecessary spaces, comments and by shortening variable names if possible
- concatenate multiple javascript files together to reduce the HTTP traffic
- shrink and concatenate CSS files
- interning HTML template files (the dojo widget system uses external HTML template files for easier maintenance). You can really *optimize the performance* of your web application if you use the dojo build system.
For loading dojo you need:
*Build command* | *dojo.js size* | *loading _/dojango/test/_* | *release directory size* | *What is included in dojo.js* |
no build | 5 kB | 7s, 193 requests (114 JS, 23 CSS) | 34 MB | Just a small stub dojo.js, that triggers a lot of AJAX requests to load javascript files |
```./manage.py dojobuild dojango``` | 81 kB (275 kB uncompressed) | 4s, 118 requests (89 JS, 2 CSS) | 16 MB | dojo core |
```./manage.py dojobuild dojango --minify``` | 81 kB (275 kB uncompressed) | 4s, 118 requests (89 JS, 2 CSS) | 7.7 MB | dojo core |
```./manage.py dojobuild dojango --minify_extreme``` | 81 kB | dojo.require fails on several files, because every used module must be added to the build profile! | 2.7 MB | dojo core |
```./manage.py dojobuild dojango_optimized``` | 419 kB (992 kB uncompressed) | 2s, 32 requests (3 JS, 2 CSS) | 18 MB | dojo core, dijit-all |
```./manage.py dojobuild dojango_optimized --minify``` | 419 kB (992 kB uncompressed) | 2s, 32 requests (3 JS, 2 CSS) | 8.6 MB | dojo core, dijit-all |
```./manage.py dojobuild dojango_optimized --minify_extreme``` | 419 kB | 2s, 32 requests (3 JS, 2 CSS) | 3.7 MB | dojo core, dijit-all |
Before starting your own build you first have to download a dojo source package and place it within dojango. See AddDojoSource for details.
Dojango makes the building of a packed release a really simple task; for that the manage command of django was extended and you now can get a build as easy as that:
./manage.py dojobuild
If you call this command, a dojo release will be created. This dojo release, as you can see in the table above will contain the dojo core library. There are no widgets or UI things included yet. It will be stored in the directory
mysite/dojango/media/release/dojango-with-dojo1.3.1
After your first build you can use that release within your project by defining the following in your project's *setting.py* file:
DOJANGO_DOJO_PROFILE = "local_release"
DOJANGO_DOJO_VERSION = "dojango-with-dojo1.3.1"
This build is actually interning all the dojo core libraries and the dojo parser (which is responsible for triggering the widget creation after the page load). If you want to customize your build and add your files this is the best starting point!
The ```./manage.py dojobuild``` command also has several parameters you can use to customize the build. By appending a dojo build profile name to this command, another build profile, as defined in the DOJANGO_DOJO_BUILD_PROFILES setting will be used instead of the default one ("dojango"). As shown in the table above, there is an optimized build, that interns even more dojo stuff, one of them being all the widget namespace (dijit.*), those are things like combo boxes, tree, layout manager, various form elements, and much more. Use the following command to create this build:
./manage.py dojobuild dojango_optimized
A name for the built release can also be defined on the command line like that:
./manage.py dojobuild --build_version=mysite1.3.1
That will generate all the built files into:
- mysite/dojango/media/release/mysite1.3.1*
There is also a switch to do a dojo mini build. A mini build is a dojo build, where unescessary files, like tests, templates and demos are removed. You can create a dojo mini release with dojango by appending ''--minify'' to the dojobuild command:
./manage.py dojobuild --minify
Now there is also the possibility doing an extreme minification. This is accomplished with this dojobuild command:
./manage.py dojobuild --minify_extreme
With this option you have to care on your own, that all dojo modules that are needed in your web application are included within your build profile, because all other js files than ```dojo.js``` will be removed. So a ```dojo.require``` on dojo modules that aren't included in the build would fail.
With the following settings you can manipulate the behavior of the build system within your project's settings file:
Dojango provides two example build profiles that you can use immediately. Possible values:
- "dojango"
- "dojango_optimized"
What is the version name of the builded dojo release? You can define any string value for that. A recommendation is to name your release with the dojo version and a prepended project name. Something like ''mysite1.2.0''.
This setting determines, how the dojango build system is doing the minification. Since Dojo version 1.2.0 the minification is done by JavaScript and not by a shell script. Normally you don't have to change that setting if you use a current version (>= 1.2.0) of dojo.
You can add your own build profile to dojango with this setting. For details, how to define your own build profile, look at ''conf/settings.py''.
Available build profiles:
- dojango
- dojango_optimized
We mixin this dictionary to each DOJANGO_DOJO_BUILD_PROFILES element. Normally these values stay the same, so they don't have to changed for each dojo build profile.
What is the commandline call for java? This is needed, if you want to build your own dojo release. On some systems you have to set the whole path to the java executable.