Dojo 0.9 Update: M2

By on May 13, 2007 11:18 pm

This past Friday, we pushed Dojo 0.9 Milestone Release 2 out of the nest. This is the last milestone before Beta and the system is starting to take a recognizable shape. Only thinner.

Here’s what’s new and awesome in M2:

  • Dijit has landed! Holy cow is it fast. Stay tuned for themes and more widgets.
  • Layered builds. Slice and dice your builds any way you like to achieve maximum performance
  • Style code is now even faster
  • Lots of new modules, bug fixes, and quality APIs

As mentioned in the last 0.9 update, we’re targeting something on the order of 50K (pre-gzip) for Dojo Base, and with a little help from Packer, we got M2’s Base under the wire at 43K (20K gzip). For the folks following the toolkit size wars at home, that’s the same gzip size as the latest Prototype release. It’ll get ever-so-slightly larger for robustness fixes, easy node creation, and color-based animations.

Dojo Core in M2 now includes ports of dojo.rpc,, (JSON-P, etc.), and AdapterRegistry. And it’s all unit tested.

The big news, though, is that Dijit now runs on Core!

Adam Peller did most of the initial porting work to move the widget system from 0.4.x APIs to the new Core versions, and the results are nothing short of breathtaking. In many cases, widget creation time is 3-5x smaller and the dependency trees for any given build are much, much smaller. Owen Williams has put together a quick set of benchmarks that exercise the widget system infrastructure. On a bad browser (IE7), we’re looking at 10ms/widget (from markup, not programmatic) and on an outstanding engine (WebKit nightlies), as low as 1-2ms/widget. Things get even faster if you build widgets programmatically.

And speaking of programmatic widget creation, the way you declare widgets in Dijit is much improved over the old dojo.widget.createWidget() hairball. The short story is that every widget can now be created using JavaScript’s built-in new keyword. All of the mechanics of widget creation are now directly under the widget’s control, meaning that it’s easier to understand and easier to work with. Here’s before-and-after for creating ContentPane widgets from a node already in the page:

// the old way
var pane = dojo.widget.createWidget("ContentPane", 
     { cacheContent: false }, "sourceNode"

// and the new way:
var pane = new dijit.layout.ContentPane({ cacheContent: false }, "sourceNode");

The syntax isn’t that much shorter, but the meaning is much clearer. You know exactly which ContentPane widget you’re creating. This makes it easier to subclass or develop your own widgets of the same name without worry. The same thing holds true for from-markup creation:

the old way
the new way

dojoType values are now case-sensitive and there’s no auto-include system and no manifest system in the new world. If your stuff works or if it doesn’t, it’s now much easier to figure out why and much easier to optimize builds for your application because you’ll be explicitly dojo.require()-ing all the modules you need.

So should you start working with Milestone 2 or wait until Beta?

We’re planning for 0.9 Beta to land in ~1month, so if you don’t need widgets that haven’t yet been ported (Editor, tables, etc.) or are just starting development on a larger app now, it may make sense to start working with M2 or SVN versions of 0.9. If, on the other hand, you will be porting a large 0.4.x application, you might want to hold off for another month until more of the widgets fill in, more of the non-core functionality fills in to dojox, and the Porting Guide gets updated and expanded.

If you do decide you want to live on the edge, it might be best to work from an SVN checkout. Here’s the quick command to get the latest:

%> svn co dojo_0.9

Also, note that the build system no longer needs Ant. Here’s the 2-line way to build the default profile:

%> cd dojo_0.9/util/buildscripts
%> java -jar lib/custom_rhino.jar build.js action=release profile=0.9

Happy hacking!

Update: The latest Dojo SVN instructions