Login Register

Adding Dojo to Your Pages

Dojo offers many editions of its code base. At first, it might seem daunting to try to figure out exactly which one you need. To quickly dispel any worries, let me assure you that every single edition of dojo provides a fully functioning system. Whether you download one of our editions, or the full, uncompressed source code, you'll be able to perform any of the examples discussed in this book.

TODO: fold in information from the README

In order to use dojo in your HTML pages, you need three sections of code, in this order:

1. Flags

<script type="text/javascript">

djConfig = { isDebug: false };

</script>

The flags control various options of dojo; often developers will set isDebug to true in order to get debugging output on their page. (There are also some other flags related to debugging; see the Debugging section of the code for details.)

2. Include the dojo bootstrap

<script type="text/javascript" src="/path/to/dojo/dojo.js"></script>

This includes the bootstrap section of dojo, and if you are using a release build, then dojo.js will also include code for some of the dojo modules.

3. Define what resources you are using

<script type="text/javascript">

dojo.require("dojo.event.*");

dojo.require("dojo.io.*");

dojo.require("dojo.widget.*");

</script>

This section is much like java's "import" statement. You specify every resources that you are using in your code. However, note that widgets are a special case and don't need to be declared explicitly, assuming that (as is the case with the built-in dojo widgets), a manifest file defines which widget is in which resource file.