Dojo Toolkit - difficult to learn, is it worth it?
November 12, 2008 – 3:39 pm Tags: JavaScriptI’ve usually dismissed the Dojo Toolkit as a difficult, poorly documented JavaScript library.
However, Zend Framework recently decided to choose it as the default JS library to bundle with the framework. It can’t be all bad if that happens, right?
This sparked my curiosity towards Dojo again - Maybe it was time to actually try it for real, armed with patience…
The documentation
This was always the biggest problem I saw in Dojo. Sometime in the past, I had taken a look at it, and it seemed to have some nice UI widgets, but the documentation was really bad. It was confusing and difficult to figure out on my own, so I pretty much ignored it.
So has it gotten any better? Yes, slightly. The documentation on the website is still a bit poor, but it has gotten better, and there’s also another, newer, version of the documentation available at Dojo Campus, which fills many holes. The site also has some more examples on various Dojo-topics.
Still, the manual leaves something to hope for. When Dojo was first adopted to ZF, I had a discussion about it on #zftalk with Peter Higgins, who is the Dojo project leader. He told me they are working on improving the documentation, so hopefully this matter will be getting better in the future.
Getting started
Getting started is actually quite easy. You don’t even need to download anything, as you can include dojo from the AOL or Google CDN’s. Basic functionality is covered pretty nicely in the docs now, and you can easily get underway.
Using Dojo widgets, Dijits, is pretty easy too, though the manual covers the declarative approach in much bigger detail than the programmatic one. Using the declarative approach, you would add dojoType=”something” style markup into your HTML, which I personally don’t like. This caused some delays at first, as I had to figure out how the parameters given in markup translate to programmatic JS-based code. Turns out they are pretty much exactly the same.
Advanced stuff
This is where the problems start. More advanced features don’t seem to have much docs, and it’s easy to stumble here.
For example, I wanted to dynamically load a tree from the server. Show a bunch of nodes, then when you expand a node, it would fetch more from the server… I also wanted the nodes to be selectable with a checkbox. This appears to need a bit of hacking and a lot of research at first, as there is no example of such.
Luckily, the Dojo source code is quite well written, and just like with Zend Framework, it’s quite simple to figure out how things work and how to make them work like you want by reading the source, but unless you’re a JavaScript ninja, or at least a ninja apprentice, this may be a bit daunting.
I did eventually manage to make the tree load with ajax and have checkbox-selectable node (more on that in a later post). I have done something quite similar using the Yahoo UI framework, and I have to say the end result with Dojo was better.
Conclusion
So would I recommend learning Dojo? Yes!
While it is pretty big and scary at first, and it’s like banging your head to a brick wall.. the wall eventually starts to crumble and things get easier.
Dojo isn’t also just for heavy lifting. The Dojo core is quite small, and contains much of what you’d expect from JS libraries such as Prototype or jQuery. And talking about the heavy lifting, the Dijit widgets are some of the best I’ve yet seen - powerful, good looking and most of all, easy to extend, which is an important point to me.












4 Responses to “Dojo Toolkit - difficult to learn, is it worth it?”
Also consider buying a Dojo book if you want to use Dojo Toolkit extensively in your projects.
By Sudheer on Nov 12, 2008
Even though Dojo is the standard JavaScript library bundled with ZF, I still swear to Prototype or jQuery, because of their better documentation and because they doesn’t use custom html attributes. The thing about the attributes is why I definitely won’t ever consider Dojo or Dijit. The widgets may be pretty and functional, but in a production environment it’s crucial that the code is cross browser, and a lot of the widgets aren’t! And especially not the dijit editor widget.
By Tix'z on Nov 22, 2008
So far what I’ve used of Dojo work just fine in all major browsers. Also, the markup stuff they do is valid HTML, as the spec says you can define your own attributes… Most validators just don’t like them.
Of course, you don’t have to use the markup based approach. I don’t really like it either, so I just declare stuff in JavaScript.
By Jani Hartikainen on Nov 22, 2008
I also initially had a lot of reluctance to get started with Dojo but now that I have, it’s been (almost) smooth sailing.
That said, now that JQuery is also part of ZF 1.7, I now have a choice. Most apps I build don’t need the Dojo widgets and for those I feel JQuery is the way to go.
By Ekerete on Dec 14, 2008