I am in the process of creating a new web application using asp.net mvc and I am trying to choose the best JavaScript library to use. I am pretty much sure that I am going to go with jQuery but nonetheless I wanted to review the libraries out there. One reason is that I am writing a book and I want to be able to justify to the readers why I am going with jQuery and not the others.
What do I want from my JavaScript Library?
I want it to be easy (I am not a JavaScript expert)
I want it to be small
I want it to be fast
I want it to be extensible
I want good documentation and/or community support
I want good/easy AJAX support
I want it to be asp.net-friendly
I also want it to be testable (I am using TDD for this project/book)
Open Source would be nice but not required
What are my options?
jQuery – http://jquery.com/
Microsoft AJAX – http://www.asp.net/ajax/
Dojo – http://dojotoolkit.org/
Prototype – http://www.prototypejs.org/
YUI – http://developer.yahoo.com/yui/
This is a shortlist but if you want a more exhaustive, read this. I only picked these, for the simple reasons that I have heard of them and are somewhat known by the community.
3 days later
It’s been 3 days since I started this post and I have spent all that time playing around with these libraries… I have gone back and forth in my opinion on which library to use. I love jQuery’s selectors, ease of use and community support. Porototype is also very popular and somewhat similar to jQuery; but I would take jQuery over Prototype for the simple reason that I like jQuery. YUI (Yahoo! UI) library is beautiful looking and very comprehensive.
jQuery
Pros
- Ease to learn and use
- Beautiful syntax (the least typing)
- Great community support and lots of fans
- Decent Documentation
- I already own the book
- QUnit test framework (http://docs.jquery.com/QUnit)
Cons
- UI isn’t that great
- Library is not as full-featured without plugins
- Plugins are somewhat inconsistent in quality depending on the author
Prototype
Pros
- Good documentation
- Good community support
- Lots of books
- Great UI with the add-on script.aculo.us (http://script.aculo.us/)
Cons
- Couldn’t find a testing framework (but I didn’t look too hard)
- For some purely emotional reason, I prefer jQuery
YUI
Pros
- Great UI components and styles
- The best documented library out there, hands down.
- Distributed hosting of JS files – the script files will be downloaded from Yahoo server, so when my site becomes a mega-hit, it will scale better.
- Great test framework and test runner – check these demos

- The most complete library
- PDF cheat sheets for every component
Cons
- Very verbose – not as elegant as jQuery, but that’s not too hard to fix e.g. I can assign YAHOO.util.Event to a variable $E and use $E as the shorthand.
The rest
I got tired of all the research and decided to wrap it up, so I glanced over Microsoft AJAX and Dojo and realized that there isn’t enough there to justify more research.
The winner…
When I started this post, I was pretty certain my final choice will be jQuery. Then I started playing with Prototype and it looked really good, which kind of opened my eyes to the need to be open minded and objective. This lead to a more objective look at YUI and the conclusion to use YUI. I was very impressed with YUI’s look & feel, extensive documentation, testing framework and the icing on the cake was the free hosting of the JavaScript libraries. This was a really tough decision because I still love jQuery the best.
[poll id="2"]

Pingback: The Best IoC Container? | Emad Ibrahim