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, dojo.date, dojo.io.script (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
dojo.require("dojo.widget.ContentPane");
var pane = dojo.widget.createWidget("ContentPane", 
     { cacheContent: false }, "sourceNode"
);

// and the new way:
dojo.require("dijit.layout.ContentPane");
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 http://svn.dojotoolkit.org/dojo/view/anon/all/trunk 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

Comments

  • Eli

    Hi Alex,

    Are you sure the SVN path is correct? It seems to only contain a single README file. Thanks,

    Eli

  • Hey Eli,

    Yes, I’m quite sure that’s the right URL. All of the bits you’ll need are pulled in with svn:externals definitions. Give it a go.

    Regards

  • Eli

    Works like charm, thanks! Something wrong with my svn client…

  • Joey

    Alex,

    Will any of the missing widgets appear in nightly builds? I am in need of the FloatingPane widgets. Should I not count on them until 0.9 final?

    Thanks,

    Joey

  • Congratulations, Alex!

  • Joey: yes, the missing widgets will fill in via the nightlies as they land on the development branch. The “FloatingPane” widget is probably going to be removed entirely or ported only to dojox at some later date. In its place, we’ll be providing a variant of Dialog that does much of the same stuff, but hopefully with a greatly reduced code footprint.

    Bertrand: thanks. We’d like to investigate better integration w/ ASP.Net web services for doing widget data binding. Would you know who we should talk to about that?

  • Pingback: catching up « Coding with a Caffeine Rush…()

  • hi …
    Benchmark for widget parsing is showing 0 ms to create 100 buttons in 23 may nightly build ..
    here is the printscreeen …
    http://picasaweb.google.co.uk/dipench/Printscreens/photo#5068332814828067074

    My machine:
    Intel 1.8 Ghz P4
    Windows XP SP2
    Firefox 1.5.02 updated

  • excellent work! I have just recently updated two sites that used dojo 0.4.x. All the load complaints I used to have are gone! Yes, I am aware of custom builds but performance was still iffy for me with 0.4.x. For the most part the dojo 0.9 transition went smoothless. However, I have one question, in dojo 0.4.x I use dojo.event.connect(dojo.html.getElementsByName(‘…’)..) to connect all DOM elements of a certain class to a specific event. In 0.9 I have to iterate through the array given back from dojo.query to setup all the events. Is this a bug or feature? that dojo.connect can’t process arrays.

    -Victor

  • Great work. Finally attempting to implement it. I’ve now grabbed the svn version. Any news on when the beta will be released?

    Chris

  • Tim Nelson

    Are we getting some kind of editable grid with 0.9 (like http://www.editgrid.com/ )?

  • Tim Nelson
  • victori: in 0.9 Beta there’s going to be a connect() method on query() results. Should make that whole thing a one-liner.

    galgaron: probably in the next 24-48 hours.

    Tim: not for beta, but stay tuned.