Javascript - Ceate a Build with Dojo

October 2016

This tutorial is intended for people who have created a website using the Dojo JavaScript framework. Here we will discuss a key point of the framework: the build.

What is a build?

In one sentence: a build regroups of all JS files in order to reduce the calls made to the servers.

How to create a build?

In theory a build is very simple to set up: you set all the JS classes used by your site in a profile.js file and then you call a script with the options of your choice and the build is done. But in practice it is more complicated, as it is not always easy to understand the interconnections between the different elements.

Step 0: prerequisite

The build uses the Rhino framework (a Javascript engine coded in Java) from Mozilla. It is present in the sources of the build, however it requires that you have Java JRE 1.4.2 or higher installed on your computer.

Step 1: Download sources Dojo

The basic version of Dojo provides 3 folders; Dojo, Dijit and Dojox. It lacks a critical folder called as: "util". This folder contains all the tools to create our build.

Step 2: Prepare your classes

This step is simple but critical: you must identify the names of all your JS class declared in Dojo [all the "dojo.provide("myfolder1.myfolder2.MyClass")].
For each of these classes, note:
  • the name ("myfolder1.myfolder2.MyClass")
  • Its relative path from the "buildscripts" folder.

Step 3: Create your profile.js file

  • Now that you have the class names and classpaths, go to the "buildscripts" > "Pofiles" folder.
  • Several profiles already exist, create a new one based on the existing baseplus.profile.js and then rename it as myprofil.profile.js;
  • The Baseplus profile contains a single layer and the two paths (code) needed for this layer. Now it is very simple:
    • keep the dojo.js layer and replace the class name by yours.
    • add prefixes to all your paths (example : "myfolder1.myfolder1 : "../../myfolder1/myfolder1")

Make sure that your prefixes point to the right folder!

Step 4: Create a release folder

  • Go back to the root folder where you unzipped the archive (the one with dojo, dijit, dojox and util) and create a new folder called: "release". This folder will contain all the files created by Dojo.

Step 5: Start the build

  • Run the script in command line:
  • Windows: Start - Run - cmd
  • In the console that opens, navigate to buildscripts file using the command "cd <mydirectory>".
  • Once in the buildscript folder, run the following command:
    • build.bat profile=monprofil releaseDir=../release action:clean,release releaseName=1.0 cssOptimize=comments optimize=shrinksage mini=true

You can launch build.bat with various options:
  • profile: the profile file that you created.
  • releaseDir: relative path to the release folder created.
  • action: Here we clean the release folder and makes a new one.
  • releaseName: name of your release (Version 1.0 for example)
  • cssOptimize: "comments - all CSS comments will be removed and compress everything.
  • optimize: "shrinksafe" request the build to compress the final JS files.

All options are listed here:

Step 6: Copy your sources

Once the build is complete, return to your release folder: It normally contains multiple folders and a copy of each file that you entered in the profile.js via prefixes. This is normal.


Related :

This document entitled « Javascript - Ceate a Build with Dojo » from CCM ( is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.