Javascript - Ceate a Build with Dojo

April 2018

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.
In one sentence: a build regroups of all JS files in order to reduce the calls made to the servers.
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.
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.
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.
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.
  • 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!
  • 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.
  • 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:
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.

Published by deri58. Latest update on April 25, 2013 at 09:42 AM by deri58.
This document, titled "Javascript - Ceate a Build with Dojo," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (
Structure your Javascript with Dojo
Javascript - Stack and queues