For full disclosure, I used jQuery with Domino long before v8.5 at a time when the dojo documentation sucked big ones and it was nearly impossible to figure anything out. Today though that is much improved and the dojotoolkit website and the work done by sitepen have done a lot to catch up.
I am more familiar with jQuery syntax and the core library capabilities and I think I will always prefer to use jQuery than dojo given a choice and even playing field. In traditional Domino it is a level playing field as neither library is loaded by default. But that all changed with XPages and I am forcing myself to have to learn dojo because it just doesn’t make sense to use jQuery “just cos dojo sucks”.
jQuery does not conflict with dojo and can be used very successfully in tandem with each other. But there are some things to consider before you do.
jQuery selectors are IMHO easier to read and more intuitive to understand. jQuery uses a combination XPath/CSS query selection process and dojo uses a CSS3 selector paradigm
So why shouldn’t I use jQuery?
If you are going to add jQuery there has to be a good reason/purpose other than “‘cos I like jQuery and dojo sucks”. If you add a jQuery library you are:
- adding additional overhead to the database
- adding potential maintenance issues down the road
- adding to the download size of every XPage which already has the dojo overhead by default.
- (Yes you can turn dojo off but why would you? If you not going to use the XPage functionality don’t use an XPage design element……)
So if you are just doing a basic selector to get a page element or a basic animation, there is really nothing dojo can’t do any worse than jQuery. If you want to see a simple comparison between dojo selectors and jQuery selectors check this out
Dojo & jQuery side by side. Part 1: DOM Basics
Dojo & jQuery side by side. Part 2: Animation
So when should I use jQuery?
When you can’t do something you need to in dojo, or just just does not make sense to re-invent the wheel. jQuery is now more popular than Flash in terms of web usage for the most popular sites. dojo isn’t even on the map when it comes to web usage tracking. In terms of community size and usage jQuery dwarfs
dojo everything else and because of that there is a lot of libraries to chose from.
In an XPages environment, the real benefit is not so much using jQuery itself, but in taking advantage of the thousands of plugins available which other people have written. There are plugins for everything from:
- Embedded video players
- Photo galleries
- Page Design libraries
- Effect libraries
- MVC Framework design libraries
I think I am going to start a series of weekly jQuery plugin examples (in XPages) to show what can be achieved very easily with the minimum of code. Let’s see how far it takes me before I run out of the over 4000 jQuery plugins and jQuery mobile