Listing the dependancies of a Dojo widget
Posted by Shane O'Sullivan on January 4, 2007
The problem with this approach is that you have to include these script files in exactly the right order, otherwise Dojo’s packaging system will remotely load these files for you. I list three solutions below, skip to the last one if you’re lazy and just want the easiest way to solve the problem🙂
One way to figure out the correct order is by trial and error, using Firebug to see which combination results in zero Ajax requests. This is how I originally approached the problem, but obviously this is labour intensive, and has to be redone for every release of Dojo.
A second approach is to use Dojo’s build system to figure this out for you. To do this, open a command window in the /buildscripts folder (um, I should have said that you have to have a build of Dojo checked out from Subversion for this, and Java 5 installed), and type
java -jar lib/custom_rhino -opt -1 -e “var dependencies = [‘dojo.widget.FilteringTable’]; load(‘getDependencyList.js’);”
This will output all the files you need, unfortunately including all of the base files that are only supposed to be baked into the dojo.js file, and you don’t want them. So, to find out what files to subtract from the first list, type:
java -jar lib/custom_rhino -opt -1 -f profiles/minimal.profile.js
This gives you a smaller list of files. Subtract these from your original list, and those are the files you need for your widget.
Finally, the third method is that you download an XML file which contains all the dependancies listed on a per widget basis. The files that you need are dependant on what profile of Dojo you use, as some of the required files are probably baked into the base dojo.js file. So, here’s some I created earlier: