I am trying to convince those who set standards at my current organization that we should use jQuery rather than Prototype and/or YUI. What are some convincing advantages I can use to convince them?
One advantage of jQuery is the large community which has developed a multitude of plugins.
The 3 main advantages of jQuery are:
- its light weight when compared to other javascript frameworks
- it has a wide range of plugins available for various specific needs
- it is easier for a designer to learn javascript as it uses familiar CSS syntax. jQuery is Javascript for Designers
I am a Prototype person, but I've used jQuery a bit. Honestly I don't there is much between the two that you can use as a 'selling point'. The YUI on the other hand is pretty bloated. I would never use it on any commercial grade application.
I found this page that talks about this exact subject.
In my opinion, having briefly tried Prototype, and then later trying and loving jQuery: the jQuery API just feels much cleaner and well thought out. John Resig, the creator/architect of jQuery really knows his stuff, and it shows in the design of jQuery, as well as the various other impressive JavaScript projects that he has been a part of.
The whole concepts of querying and chainability fit very well with DOM manipulation, which seems to be the brunt of what people use JS libraries for. The online documentation is fantastic. Performance seems to be very good as well. The entire library fits into a relatively small package given it's capabilities. The plugin architecture is also very nice for extensibility.
I honestly haven't tried YUI, so I can't comment much on that. I do know that it is a rather massive library in total, though you can choose to download/use only specific modules of it.
Maybe you shouldn't? It all depends on what kind of application(s) you're building. If you are building GUI intensive applications, something like, say, Yahoo! Mail, then maybe you should consider using YUI or Mootools over jquery. Personally I'm a huge jQuery fan, but it is definitely best for adding a touch of interaction to an otherwise mostly static UI. On the other hand, if that is what you'll be using it for, then jquery is a lot simpler, has nicer syntax, and it has a lot of momentum.
It's very small, especially when minified, and offers a lot in the core library.
It's also easy to extend, and has an active community.
- Finally, it's extremely easy to learn; once you've grasped the core concepts you can start coding complex solutions right away.
I would say my top reasons for using JQuery are:
- Large development community and many plugins.
- It's on Microsoft's radar and they are adding some plugin support and debug capabilities.
- Very good documentation for a 3rd party library.
- Lightweight.
- Chaining capabilities are very powerful.
Why don't you create a quick comparison?
Take a task like "find all divs or tables which contain images of class foo and attach a click event to each of them which makes them expand 50%." Or something more relevant to what you're doing.
Then code that with jQuery, Prototype, etc, and compare. Which is shorter? Easier to read? Faster to run? (You can find a speed comparison here.)
One argument in favor is this:
popularity + extensibility
1) If anyone needs to do X with JavaScript, it's probably been done with jQuery
2) If it's been done much, there's probably a plugin, if not native support
And if it's really unique, there are a lot of people to answer your question on SO or elsewhere.
It has a good set of plugins and the coding style is unobtrusive which means it's not too hard to replace. There is also a nice drop in replacement for Ruby on Rails helpers called jRails.
Performance-wise they are all pretty close: http://www.kenzomedia.com/speedtest/ However, MooTools, dojo, ext, and Prototype all run faster in my environment.
My question is- why do you want to use it? Is it just because you know it better?
Jquery has been around for a few years, so like everyone else has said, it has a deep community, lots of plug-ins, and decent support. What set it aside for me was that it's easy to learn.
It's the most well though out language you'll find -- it's almost intuitive.
Want an element's width?
$('#something').width();
Want to grab an element, hide it, change it's background color and fade it back in?
$('#something').hide().css('background', 'red').fadeIn();
How about table striping for IE (assuming 'hover' class is defined)?
$('table tr').hover(function() {
$(this).addClass('hover');
});
It's quick, mindless work like this that really helps sell jQuery.
Here's a more recent speed test than the one provided above. Last time I ran it dojo was the fastest followed by jQuery, Mootools, Prototype, and finally YUI. Note I ran it in Firefox 3 and the speeds vary between browsers so test it out yourself.
If you are trying to convince people from a business perspective, Microsoft's recent decision to ship jQuery with Visual Studio could help establish some additional credibility. Then again, that could hurt your cause, depending on their opinions of Microsoft.
I have been using jQuery for a few months now and have found it an enjoyable experience. The framework is clear and concise it has a great plugin architecture and is very well supported but frameworks are a very personal thing though and you should probably try a few it doesn't normally take long to spot the one that feels best for you.
Not sure if this will matter to you but Microsoft recently announced support for jQuery in the next update for VS 2008 Here is the blog post.
You can hear the John Resig, the guy behind jQuery, talking about it a various other frameworks on a recent Boagworld podcast. It might help you make up your mind its a pretty balanced piece.
You can follow link text to knw more about jQuery, Why to use it and What are it's advantages.