Jquery, Mootools, Prototype or Plain Javascript?

4 points by mrfish ↗ HN
I love to make fun UI's with Javascript. I primarily use jquery because it is well documented with examples and works across multiple browsers, it's easy and I havn't learned the other frameworks enough to give it a fair comparison. Comparied to native Javascript, I know what the benefits are and recently I've been exposed to Mootools which appears on the surface to have less functions.

So my question is, what's the difference? and when would I choose one over the other?

6 comments

[ 3.8 ms ] story [ 27.2 ms ] thread
The best library to use is the one you KNOW best. As you have already experience with jQuery, my suggestion is you stick with it. In any case IMHO it is the best JavaScript library in any case.

Things to experiment with besides jQuery:

(01) Base2

(02) YUI

These have helped me learn better JavaScript. YUI is an excellent library, but I can't stomach their namespacing, it is just too long for me, whereas Base2 have helped me learn a few things about better object orientated scripting.

The best advantage for jQuery for me is that I can remember almost all the methods. I rarely need to look up things and by now, I can also open up jQuery itself and I understand how it is working. The sizzle engine that it currently uses is one of the fastest selector engines.

I recently had to compare jQuery, YUI (2.0), and Ext for a project heavy on AJAX, client-side data sorting and filtering, and dynamic graphing. Here's my take on them. (Note that I already knew jQuery and was looking at YUI and Ext as potential replacements because of their extensive widget sets.) ::

- YUI has a lot of nice widgets, but the organization of its documentation made it hard to learn. Moreso, YUI doesn't make writing JavaScript any easier. I found myself writing dozens of lines of code to do seemingly simple things. And YUI 2.0 didn't seem to have as simple a way to query the DOM as jQuery.

- jQuery is at its core a framework that makes writing cross-browser JavaScript very easy, with very few lines of code. And the jQuery UI add-ons and plugins provide the widgets. Unfortunately, the plugins aren't consistent and they trail behind YUI and Ext in terms of features. But I felt like a jQuery expert in just a couple hours and can't imagine writing complicated scripts without it anymore.

- Ext has a very extensive, professional set of widgets (datatables, datepicker, charts, etc., etc.). It also seems to provide DOM querying in ways that are as simple as jQuery's. But the widgets feel very "heavy" and Java-like to me, rather than light and JavaScript-like. I found that I often couldn't write my own js or CSS to manipulate a widget after it was rendered; I had to use the widget's events and hooks. Hence, sometimes it just feels "heavy." Note also that Ext 3.0 doesn't have very good documentation yet, even though it's the default package available on the site.

Ultimately, I ended up mixing jQuery and Ext to get the framework/querying from the former and widgets from the latter.

> Unfortunately, the plugins aren't consistent.

You correct in this respect, but what I found possible was for me to fork some of the plugins. With Ext, I could never dream of doing that in any reasonable time-frame. The last time I had a look at Ext I could not understand if it was possible to introduce some sort of progressive enhancement. Has this changed?

Long term the jQuery UI will provide the full set of these widgets, especially since some big names are supporting the organization now. John was a brilliant marketer as he understood what developer wanted. $ not YAHOO.something.something. $().css({}) not Something.Something.getCSS().

IMHO if you look at the evolution of computer languages, Coders always went for the shorthand versions, C won over Pascal as it did away with Begin .. End. This can be applied to all the libaries. It is actually common practice for Coders working with verbose languages such as PHP, to have their own stash of util functions with shorter names. Know Thy Market!

You already use and like jQuery. It's good. It works. You know it. Stick with it.
+1 for jQuery. To me, it's one of the best thing that happens to me in my developing career. A lot more miles with a lot less fuel.

One thing I may suggest tho is that if you have a page that gets hit with a lot of traffic, you might consider out sourcing you jJavaScript.Query file or just use plain