Dojo build layers provide a clean path from development to production when using Dojo for your UI layer. In development, you can have load-on-demand, rapid application prototyping; a build layer takes all Dojo dependencies and compiles them to a single file, optionally stripping whitespace and comments, and performing code heuristics to allow further minification of variable names. Additionally, it can do CSS minification.
In order to create a build layer, you would traditionally create a JavaScript file that has dojo.require statements for each dependency, and optionally some additional code that might run when the script is loaded. As an example:
dojo.provide("custom.main");
dojo.require("dijit.layout.TabContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.form.Form");
dojo.require("dijit.form.Button");
dojo.require("dijit.form.TextBox");
This script is generally referred to as a "layer" script.
Then, in your application's layout, you'd instruct Dojo to load this module:
<html>
<head>
<script type="text/javascript" src="/js/dojo/dojo.js"></script>
<script type="text/javascript">
dojo.registerModulePath("custom", "../custom/");
dojo.require("custom.main");
</script>
If you use Zend_Dojo to do this, you'd do the
following:
<?php
$view->dojo()->registerModulePath('custom', '../custom/')
->requireModule('custom.main');
But since Zend_Dojo aggregates your various
dojo.require statements, how do you create your layer
script? You could open each page and view the generated
dojo.require statements, and cut and paste them into a
layer script file manually.
However, a better solution exists: since
Zend_Dojo aggregates this information
already, you can simply pull that information and build your layer
file. This is the purpose of
Zend_Dojo_BuildLayer.




