I was recently discussing the merits of jQuery with a colleague when he asked the inevitable question: What do you think is the best JavaScript framework? The answer to that question is too broad for me to detail here. However, he followed by asking me specifically about MooTools.

A Little History

I recalled that years ago I asked myself the same question. After some extensive (read: cursory) research, I settled on MooTools. I remember fighting for days to get an accordion widget up and running. To be fair, I was rather green.

Eventually I became quite versed in manipulating the DOM with MooTools. I loved MooTools so much that I scoffed at other frameworks.

Then I found a new day job, and guess what? Their design infrastructure demanded that I learn jQuery. For many reasons—some of which I’ve concentrated into the list below—this was the best thing to happen to me since learning “alert();”

The Inspiration

After regaling my friend with a lengthier version of the above, I decided to search for the most recent thoughts on the debate. This is how I found jQuery vs MooTools by Aaron Newton of Clientcide. After reading the article, it was plain to me that Aaron Newton is a smart entrepreneur, an elitist, and a master of manipulation.

His article is loaded with extreme bias toward MooTools, as well as some subtle wording tricks that emphasize how much better MooTools is. He unfairly states in his disclaimer, “Obviously, I have a perspective that is somewhat biased,” only to follow up with, “My objective here is to be helpful and accurate to people – not to sell one framework over another.” Yet, he often cleverly accentuates that MooTools is more explicit, makes more sense (to him), is more robust, and is easier (for him) to use. He silently calls to the inner “elitist/pedant” that resides within all good programmers (even me). MooTools is the right way, the strong way, the one true JavaScript ninja stance. To completely paraphrase and prune his entire article down to two sentences, I offer the following:

Ain’t jQuery a cute, easy to use little toy? MooTools is for “know-betters” who do things besides manipulating the DOM.

Much to my further chagrin, Aaron thoroughly reiterates throughout the document that he does not know what he is doing when coding with jQuery:

“[jQuery’s] methods don’t always make sense to me … When I do work with jQuery, I often find myself unsure what a method is going to return to me. Obviously this doesn’t bother everyone else as jQuery has a lot of people happily using it, so I’ll chalk it up to personal preference again [and again, and again, and again].”

I encourage Aaron to RTFM.

Most of the code examples that he provides for comparison emphasize how “MooTools code is … more verbose [than jQuery], but also more explicit.” I believe that Aaron is afraid of abstraction.

The List

I must thank Aaron, because he inspired me to write this jQuery-biased, yet non-partisan list of the top ten reasons (according to someone who is familiar with both frameworks) why you should use jQuery, and why I will never go back to MooTools.

I promise to keep my opinions to myself from this point onward. False.

10. Write Less, Do More

Aaron explains it best. “MooTools … takes longer to learn and requires you to write more code.” In the real world, we all want to write less and do more, do we not? Therefore, if my framework forces me to write more code to accomplish the same result, I must ask myself why I am using my framework. That leads me to the next reason.

9. 99% of all JavaScript is written with the intention of manipulating the DOM

If you were to make a list of the things you need JavaScript to do for you, it would look like the following:

  1. AJAX
  2. Form validation
  3. Animation
  4. Event handling, and
  5. Traversing the DOM

Both frameworks will allow you to do these things, albeit jQuery allows you to do them faster and easier.  Occasionally (1% of the time) you discover that you need to perform some complex logic. With jQuery you’ll have to write some plain ‘ole JavaScript, whereas MooTools offers quite a few tools to handle these (1%) situations.

I wave my magic wand and now you’re a carpenter. Your task is to build 100 houses. You have two magical super tools at your disposal, and must choose only one.  One of them will allow you to hammer nails, measure and saw wood, drill holes, and cut a variety of special and complex wood joints.  Only one of the 100 houses will require the complex wood joints.  The other tool just hammers nails, cuts wood, and drills holes, but it does so with half of the required effort.

8. Abstraction

This is pretty much the same reason as number 10, but I felt like it required further emphasis. The reason you are writing less code in jQuery is that the library whisks-away all of the more explicit JavaScript that you would otherwise have to write. This is the only reason anyone uses a framework in the first place.   More Code = Less Abstraction = Less Productivity = jQuery Wins.

7. Selectors

jQuery uses CSS selectors.  You can grab an element by id, but you can also quickly grab all elements with a certain class, or all form inputs, or all form inputs that are password fields. It’s amazingly simple. This eliminates many hoops that you would otherwise need to jump through. It also makes working with designers a breeze.

6. Plugins

Back when I was forced to switch to jQuery, this was the first thing that I started to love about it.  Do you need to do something that the jQuery core does not do?  There is a plugin for that.  Hell, there are 10 plugins for that, each with their own level of complexity, and most use a single line of code to incorporate into your project.

MooTools has plugins too.  Again, you need to write more code to implement them, and there are FAR fewer options available.  This is because MooTools encourages you to write your own.  I am sorry, but I am too busy standing on the shoulders of giants to bother.  I will be drinking cocktails and toasting to my successful deadline completion while a MooTools developer is figuring out how to write a plugin to accomplish his goals.

I love original code.  Writing new code is fun!  However, that is not why I use a framework.  I use a framework to make my life easier.

5. Speaking of plugins: jQuery UI

jQuery UI is the single greatest web developer’s friend. You get tabs, dialogs, accordions, a progress bar, and sliders; it has pretty much everything you need to make a smart little web application.  If you program with jQuery, you are doing yourself a disservice if you are not using jQuery UI for some of your projects.  MooTools has a couple of options too, like JxLib and Mocha UI. I really dig the Mocha UI canvas approach, but I’m convinced that neither of these are as easy as jQuery UI.

4. Who needs MooTools?

Here’s Aaron again to further my agenda: “Most of the code you write when you write MooTools still feels like JavaScript.”  That’s because it still is JavaScript.  MooTools is a collection of extensions and prototypes.  MooTools makes low-level tasks a bit easier while ignoring that what you really want to do is just make things work.

3. The community is amazing.

Popularity is an annoying yet powerful thing.  jQuery is freakin’ popular, as shown here by Google trends. There is a veritable plethora of jQuery developers out there to answer your questions, build amazing plugins, ferret out bugs, and basically make everyone’s life easier. MooTools supporters say that jQuery fan boys talk loud and promote jQuery more than they ever can. This is true, but it is a symptom of the underlying issue. jQuery makes itself so easy to promote.

2. Google uses jQuery.

So does many other respected names like Digg, Technoratti, WordPress and Drupal. What is that famous saying about the company you keep?

1. Speed

Mootools is fast. jQuery is faster, period. This became especially true after jQuery 1.3.

The Last Word

Go download jQuery, take the brief amount of time that is required to read the documentation, and thank me when you’re done.

If you think you can convince me that MooTools is worthy of another look, or if I’ve misrepresented your framework, by all means let me know in the comments.

Related posts:

  1. DreamInCode.net – The “52 Weeks Of Code” Challenge!

Tags: , , ,

Commentation