I do not wish to discuss jQuery here but apparently no Dojo blog is complete without a discussion about jQuery vs. Dojo so to get this out of the picture I post this as early as possible.
Many men, wiser than me, have written about this but here is my take on the subject. I think it is very similar to other answers you can find on the internet.
NOTE 1: I have not used or looked at jQuery since mid 2011 and things may have changed.
NOTE 2: Dojo and jQuery are not the only games in town, but I am not qualified to talk about any of the other libraries.
Dojo or jQuery, quick answer
- Dojo if you have a large project and can spend time on a very steep learning curve and want to be able to create and re-use widgets, data connections and whatnot.
This answer do not take into account the “fun factor”. If your aim is to have fun JQuery will give you a quick fix but Dojo will be more rewarding in the long run. Your choice.
Dojo or jQuery, not so quick answer
First I want to point out that the question is kind of silly, really, and if you even ask you probably want to use jQuery. Dojo and jQuery are for different problem domains. Dojo is really a superset of jQuery and solve some problems that a beginner jQuery user did not even know existed.
But here is a comparison between JQuery and Dojo anyway:
JQuery vs. Dojo, round 1: Documentation
JQuery documentation wins hands down. No contest. Dojo documentation has improved enormously since I first looked at it a few years ago but it is far from good. Sometimes the only information you can get is the name of the widget. This is, in fact, my main concern with Dojo and a big part of the reason I started this blog. I hope it will somewhat ease the learning curve at bit.
The explanation is probably that Dojo is open source and contributors do not get paid to write documentation. This is, however, also true for JQuery but that project must have some magic way to get its contributors to produce documentation.
I will speak more about Dojo documentation. In the future. I have opinions.
Now, you could argue that JQuery documentation is really only good for the JQuery core and JQuery UI and Dojo contains so much more. This could be a valid argument but in reality JQuery documentation is much much easier to grasp, understand and use.
JQuery vs. Dojo, round 2: Learning Curve
Dojo does not really have a learning curve, it’s more of a step or even a Dirac-pulse. There are many things you must get right before you can even begin. It’s not easy to sneak some Dojo into your page, unless you already know Dojo quite well.
jQuery, on the other hand have a, I would say, quite flat learning curve. You just need to learn to find your way around in the documentation.
This round goes to jQuery.
JQuery vs. Dojo, round 3: Code organization
This is something Dojo does and jQuery don’t. Dojo more or less force you to organize your code and make modules (classes and widgets). As far as I know jQuery do not address this at all so you get no help here.
For a small project this may not be a problem during development, but Dojo is not only for small projects. From a maintenance point of this will probably be a problem for jQuery projects.
This is not to say a jQuery project cannot organize the code, only that jQuery do not help you with it.
Round to Dojo.
JQuery vs. Dojo, round 4: Code re-use and modularization
This is also something Dojo do and jQuery don’t. It is not only simply re-use of code that you written once but you can, for example, write some code that retrieve data from and update to on your server and let Dojo-front ends like lists and pulldown menus use this code to interact with your server. (I’m not saying this is necessarily easy, but by design it is possible)
JQuery vs. Dojo, round 5: Page design in mark-up.
Dojo win by default.
JQuery vs. Dojo, round 6: API Stability.
I cannot say for sure but the Dojo APIs seem far more volatile than the jQuery API. The Dojo developers seem to delight in adding a new feature only do declare it deprecated a few releases later.
For example, the changes between 1.6 and 1.7 broke much of my code. Badly. I then rewrote it for the AMD API and that changed even more. I fear the 2.0 release but I must confess that I also like the new features so changes in the API is not all bad. It can sometimes also be argued if it is the API or inner workings that have changed. Such an argument would be easily solved by looking the documentation, you would think, but alas, not for Dojo.
I guess, for API stability, jQuery gets this round.
JQuery vs. Dojo, round 7: Performance.
Well, I cannot tell and from my perspective this is not a very interesting issue. I mean the difference is not big enough to be a major factor.
To me, this round is a draw.
Result: jQuery or Dojo?
It’s all up to you and your needs and preferences. Choosing Dojo comes with a cost but also with some long term benefits.
Some have suggested, as a solution to this Gordian Knot, that you can use both. While this is probably possible you will no doubt reduce your performance and double your page load times. The only reason I can see is to re-use some jQuery code in a Dojo environment but since Dojo can do (almost?) everything jQuery sort of doubt this is a good idea.
Who am I to say all this?
So I have opinions about Dojo and jQuery. Who am I and why should you trust my opinions?
Well, for starters, you should not trust anything you read on the internet and you should also remember that an advice is worth exactly what you paid for it, but here is my story:
After a year and a half or so (I have other tasks, so it is not 2000 hour of coding) I started to suspect I had problems. Whenever I let the project rest for a few days I noticed that it became more and more difficult to pick it up again.
But it did feel like re-inventing the wheel and it did not feel comfortable to make all this that should really have been there from start.