Why Don't You Use Dojo?

by Matthew Russell

I've slaved away for the past 8 months or so writing a book on Dojo. It's definitely not a lot of fun moonlighting for such an extended duration on a single project, but my hope is that it's all going to be worth it when I am able to deliver what I believe will live up to the "definitive guide" standard that so many other O'Reilly books have delivered in the past. (Yes, that previous link shows that the book is titled Developing with Dojo, but it's really just a placeholder. The book has since been retitled, there will be a different animal on the cover, etc.)

The fact that I've spent so long working on what's essentially documentation of all things should tell you that I'm a huge Dojo advocate, but why did I like Dojo enough to spend hundreds and hundreds of hours writing a ~500 page book on it?

Here are some of the reasons that come to mind immediately:

  • Breadth and Depth - It includes a highly optimized JavaScript standard library that protects you from the bare metal of the browser and allows you to write portable code, a terrific set of widgets that you can drop right into the page, and build tools that you can use to compress and consolidate your JavaScript to squeeze as much performance out of it as possible. Those are really broad strokes, but hopefully you get the idea that it's not just about widgets or just about DOM manipulation. It's about creating a great user experience and necessarily includes a swath of stuff that helps you to make that happen.

  • Awesome Community - The help these people have given me in writing this book is nothing short of incredible. It's kind of strange to "know" people for months and months via an IRC chat room and somehow feel like they're your friends, but that's the way it feels. It's amazing to watch some of the most hard core committers in the project field some of the simplest questions that come up with grace and patience. (And believe me, I've come really close to starting a riot a few times in there.) Drop into #dojo on freenode.net if you ever want to see just how inviting the place really is.

  • Clean, liberal, licensing - This post does a great job of explaining, a lot better than I could right now, so have a look.

  • Pragmatic philosophy - It doesn't try to re-invent JavaScript or build a brittle, artificial language on top of it. It embraces JavaScript for what it is, plugs holes where they need to be plugged, smooths a few things out here and there, and otherwise leaves the language alone.

Now, without starting a flame war, I'm curious about some things:

Have you tried to use Dojo in the past and gotten frustrated and dropped it for something else? If so, why (and what did you end up liking better?)

Would a solid book on Dojo have made a difference?

Have you started with another JavaScript toolkit but migrated to Dojo because the other one didn't quite meet your needs? You don't have to say which one you moved away from, but it would be interesting to know why you ended up moving to Dojo.


Larry Kubin
2008-02-22 10:45:44
We like Dojo here and even integrated it with our web framework (http://www.stratosframework.com). This was done with version 0.4x. One thing that was particularly frustrating was the big overhaul of the Dojo website when it switched to Drupal. A lot of the documentation wasn't really organized well, but now it's coming together again. I also used to think it was kinda slow and overweight, but it seems much better now since the release of 1.0, and including it using the CDN is nice. So I did start exploring other toolkits like jQuery, but Dojo is looking pretty solid these days.
Josh Peters
2008-02-23 12:42:49
The last time I tried Dojo I was infuriated at the lack of documentation. YUI clearly had them beat there.

The licensing of YUI is BSD; it's hard to find a more flexible license. The examples are also top-notch and the support is great. In addition, the fact that Yahoo eats its own dog-food communicates to me a level of polish and trust in their toolkit.

I don't know if it's worth looking at Dojo ever again.

2008-02-23 12:59:34
@Josh Peters: Interesting thoughts. I think you have a fair point on the documentation although it has improved significantly since the 0.4 days. Actually, last night the documentation got significantly better because the API is now exposed at http://redesign.dojotoolkit.org/ in a lot more cleaner way.

As for YUI!, yea, I think it's really good work too. Yahoo! has been doing a lot of interesting work, and I am also big on eating my own dog food. However, one thing that bothers me about YUI! is that it's not really OSS as there is no visibility to the SVN trunk, external committers are not allowed, and it's not clear where the IP is from. At least that used to be the case (and I think it still is.) Ref: http://dojotoolkit.org/book/dojo-book-0-9/introduction/why-dojo)

At any rate, if you're the book reading type, I hope that when a sample chapter becomes available in the O'Reilly catalog and/or Amazon, you'll give it another shot. Saying that it may not be worth looking at any technology "ever again" is kind of unfair.

Josh Peters
2008-02-23 17:25:33
@ptwobrussell: you are of course right about my "ever again" comment. It was merely an overflow of my satisfaction with YUI. Depending on how the Microsoft merger affects YUI I may have to check out Dojo sooner than I want to :)

I look forward to your sample chapter.

Mark Holton
2008-02-23 18:49:17
...a book would make a difference for me. Would be very interested to read this Dojo book.
2008-02-25 11:42:40
Dojo seemed to hold a lot of promise for me : gracefull degradation, accessibility, themes! BUT! the lack of concrete examples the slowness of it and the difficulty to put it on a CDN and have it do simple task (again documentation), made me rewritea few days of dojo work into jquery in a matter of hours.
Books are only good if the framework doesn't change radically. Online documentation should be better, and more example uses would help a lot.
Benoit Piette
2008-02-26 14:22:25
The first time I looked at Dojo (a year and a half ago) it looked promising, but the big problem for me is that it extended HTML in a non standard way that at first reminded me a lot of the 90s. It did not respect the separation between structure presentation and behavior by adding dojoType attributes everywhere.
If it used a mechanism akin to microformats I might have liked it better. There is probably good a technical reason why that choice was made (performance ?) but it basically rules it out for me. I did not check Dojo lately so it may be better at this now.

I hope I'll have the time to evaluate Dojo again soon.

2008-02-26 15:09:55
@Benoit: Thanks for sharing. One thing that I think it's important to realize is that the dojoType attributes that you can use to include a widget in markup are just convenient placeholders. When the page loads, the parser queries for them, and replaces the containing tags with the actual widget markup that it constructs. So, you're right that Dojo does not *necessarily* follow HTML 4.01 strict syntax in that the HTML file has a non-standard dojoType attribute, but at the same time, 1) it's a placeholder, and 2) you could actually use JavaScript to dynamically construct the widget and not use the parser or dojoType attribute at all--which would allow you to produce strict HTML 4.01 documents if that is very important to you. But if you end up with the same widget either way in the end, it almost seems like a moot point to go to that extra trouble. But, like I say, it's a viable option.

Also, realize that the dojoType attributes are predominantly used with widgets and things like drag and drop. All of the core language tools that are provided don't have anything to do with dojoType at all, so there's a lot of utility you could get from those, which wouldn't even necessarily give you a reason to use dojoType tags. (And BTW, the core language tools that you can load from AOL's CDN come gzipped across the wire at about 27KB -- a tiny payload for such a breadth of constructs.)

I hope you have a chance to checkout Dojo again soon. Please drop me another line when you do. I'd love to hear more about how it's going for you.

2008-02-29 01:47:05
I started using Dojo since 0.3. Used it to get over Backbase - which was very good when nothing else was around (around 2005). Aside from documentation (which is still missing for most part), the main issues with the earlier dojo were sluggish performance and bloat size. With Dojo 1.x speed has improved signficantly. However size still remains somewhat an issue. There is also the overkill factor. For simple dynamic page interaction, using all of Dojo is an overkill. Lastly, there are some very nice competitors. YUI is just one. JQuery (for simple and not so simple) usage is excellent. ExtJS (commercial), also provides a great set of widgets. So the question is not why not Dojo, the question is why Dojo? For most folks (used to using Prototype for example), it is an after-thought.

Look forward to the book.

2008-02-29 08:33:04
@vivek: Interesting. Thanks for taking a moment to share that. One thing I do want to comment about, that I think is very important though, is Dojo's build tools. If you download a source release or the subversion HEAD, you'll find an util directory that will contain a buildtools directory. Inside of it there's a fairly self-explanatory script with an extensive option list that allows you to "build" a release of Dojo. What that means is that it can minify the files (cut out white space, commenting, etc.), consolidate CSS files, intern template strings for your widgets, and then consolidate multiple JS files into "layers". In the end, you can truly have a 1-1 correspondence between pages in your application and JS files that get downloaded. Since reducing the number of HTTP calls to the server is generally the #1 thing you can do to improve page performance, this is a really important feature to be aware of for production considerations. Well, actually, there's a lot more that the build tools can do, but that's the general idea.

You should give them a go sometime. It's not uncommon to reduce file sizes by more than 50%, and when you couple in the ability potentially eliminate the overhead of a dozen or more HTTP calls, your performance is *noticeably* snappier.

Maybe I'll do another post here in a bit on the build tools.

Yuvaraj Thiagarajan
2008-06-27 15:52:38
I hear a lot about the breadth and depth of Dojo. Though Dojo had been in the development for a longer time than either YUI or jQuery, there are only a few examples and demo applications on the Dojo website that reveals the full power of Dojo. Also, the quality of the demo applications are poor when compared to YUI. Some of the demo applications in the Feature Explorer at http://dojocampus.org/explorer/ simply does not seem to work in Firefox 3.0. In my opinion, having a non-working demo is worse than not having a demo application. However, I have just purchased a Dojo book recently to see whether my impressions about Dojo change after reading and using more of Dojo, especially for those applications developed using YUI before.

In my opinion, I feel YUI has arguably the most number of user interface widgets with rich examples and very good API documentation. It is this aspect that made me select YUI, when I was looking for a Javascript library. Also, the development of YUI 3.0 focusing on speed, ease of use, extensibility and security and the decision to open up YUI for community contribution keeps me interested and motivated in using YUI.

I also felt attracted towards jQuery especially because of the easy extensions through plugins and chaining commands. But less number of user interface widgets in jQuery made me to pass it a few months before.