Learning jQuery - First impressions vs. Dojo
Posted in JavaScript on 01/23/2010 02:52 pm by JennyI spent yesterday playing around with jQuery. It’s quite different from Dojo and reminds me a lot of Prototype with a bigger community. I really like jQuery for doing DOM manipulation and find the terse syntax more appealing to write. I love the fact that it has a big community discussing, contributing, and helping each other learn. I do, however, have some concerns about how jQuery might scale up on a rich web application with a lot of functionality. The best way to find out for myself, of course, is to keep learning.
Extending the base functionality: big difference
Perhaps the biggest difference between Dojo and jQuery is the philosophy they took towards extending the base functionality. jQuery itself is best compared to Dojo base. If you want additional functionality, it’s available in user-created plugins which you download and include via script tag. In Dojo, you would find a module for this in dijit or dojox and include it with dojo.require.
Do you prefer extensions that have been planned out centrally to work together? Are you ok with having just one “official” way to do things with some configuration options? Would you rather just include the needed module and skip the process of searching for a plugin? Use Dojo.
Do you want to have the biggest number of options possible for the functionality you need? Don’t mind having to search around a little bit and compare plugins in exchange for finding one customized to exactly what you want? Use jQuery.
Dependency management
Dojo does really well here. There’s an “official way” to manage dependencies which is nicely supported by the library. You put your custom code in it’s own folder which becomes a namespace for your code. Create classes in separate files in the folder with dojo.declare and a dojo.provide statement. Just dojo.require them where you want to use them. The jQuery way is to… use the script tag? You can organize files containing the code however you want. I’ve only been using jQuery for a very short period of time, but I’d guess there are some “best practices” for organizing code that make this less of a problem when working with others.
Conclusion
The things that make Dojo great for writing complex applications are no help when trying to do simple enhancements. jQuery just makes these things incredibly easy. Just include the library, a plugin or two, and one file with your own code. I think in the future I may be using both depending on what sort of problem I need to solve.