My favorites | Sign in
Project Logo
                
Search
for
Updated May 09, 2009 by wolfram.kriesing
DojoBuild  
Help - How to pack, build, optimize the JS source code by easily making a dojo build.

Note: This page refers to the latest version from SVN trunk, to see this page for the downloadable dojango-0.3 version please go here!

Why create a build?

Speed, speed and speed. Your users will be thankful! Dojo comes with a built in build system that

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

How to create a build?

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!

Optimized and minified dojango build

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.

Customize your build

With the following settings you can manipulate the behavior of the build system within your project's settings file:

DOJANGO_DOJO_BUILD_PROFILE (default: "dojango")

Dojango provides two example build profiles that you can use immediately. Possible values:

DOJANGO_DOJO_BUILD_VERSION (default: "1.3.1")

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''.

DOJANGO_DOJO_BUILD_USED_VERSION (default: "1.3.1")

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.

DOJANGO_DOJO_BUILD_PROFILES

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_DOJO_BUILD_PROFILES_DEFAULT

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.

DOJANGO_DOJO_BUILD_JAVA_EXEC (default: "java")

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.


Comment by cpinzon, Sep 17, 2008

Hello,

Thank you for dojango.

Just a suggestion: In this section you explain how to build Dojo without a reference to the way to get the Dojo source. I propose to put just a link in the beginning of the article (http://code.google.com/p/dojango/wiki/AddDojoSource) to make it more complete.

Kindly regards,

Carlos

Comment by tobias.klipstein, Nov 21, 2008

thanks for that input. i've fixed the documentation


Sign in to add a comment
Hosted by Google Code