Javascript – Why is jQuery so widely adopted versus other Javascript frameworks?

frameworksjavascriptjquerymootools

I manage a group of programmers. I do value my employees opinion but lately we've been divided as to which framework to use on web projects.

I personally favor MooTools, but some of my team seems to want to migrate to jQuery because it is more widely adopted. That by itself is not enough for me to allow a migration.

I have used both jQuery and MooTools. This particular essay tends to reflect how I feel about both frameworks. jQuery is great for DOM Manipulation, but seem to be limited to helping you do that.

Feature wise, both jQuery and MooTools allow for easy DOM Selection and Manipulation:

// jQuery
$('#someContainer div[class~=dialog]')
    .css('border', '2px solid red')
    .addClass('critical');

// MooTools
$('#someContainer div[class~=dialog]')
    .setStyle('border', '2px solid red')
    .addClass('critical');

Both jQuery and MooTools allow for easy AJAX:

// jQuery
$('#someContainer div[class~=dialog]')
     .load('/DialogContent.html');

// MooTools (Using shorthand notation, you can also use Request.HTML)
$('#someContainer div[class~=dialog]')
     .load('/DialogContent.html');

Both jQuery and MooTools allow for easy DOM Animation:

// jQuery
$('#someContainer div[class~=dialog]')
    .animate({opacity: 1}, 500);

// MooTools (Using shorthand notation, you can also use Fx.Tween).
$('#someContainer div[class~=dialog]')
    .set('tween', {duration: 500}) 
    .tween('opacity', 1);

jQuery offers the following extras:

  • Large community of supporters
  • Plugin Repository
  • Integration with Microsoft's ASP.NET and VisualStudio
  • Used by Microsoft, Google and others

MooTools offers the following extras:

  • Object Oriented Framework with Classic OOP emulation for JS
  • Extended native objects
  • Higher consistency between browsers for native functions support.
  • More easy code reuse
  • Used by The World Wide Web Consortium, Palm and others.

Given that, it seems that MooTools does everything jQuery does and more (some things I cannot do in jQuery and I can in MooTools) but jQuery has a smaller learning curve.

So the question is, why did you or your team choose jQuery over another JavaScript framework?

Note: While I know and admit jQuery is a great framework, there are other options around and I'm trying to take a decision as to why jQuery should be our choice versus what we use right now (MooTools)?

Best Answer

That's an odd question... I get the impression that...

  1. you are very familiar with mootools and take full advantage of its OOP model, making your code easier to manage and support already.
  2. you realise that jQuery's purpose is somewhat different and tweaked towards DOM manipulation and AJAX and that mootools does do everything jQuery does AND then some.
  3. sounds as if you do not need to be using much in the way of 3-rd party plugins which makes the points of jQuery's popularity and support a bit less important.

Bottom line, is it the hype? jQuery is turning into one of these magical marketing buzzwords like 'AJAX', .NET and Web 2.0 — which is great for them but why do you need to justify staying with the framework that works so well for you? There's also the business considerations which I imagine will cover things like:

  • framework longevity, or is mootools likely to go away in the face of the ever growing jQuery — very doubtful, seeing as they just released 1.3 beta 1 and have 2.0 is in the pipelines for release by the end of the year.
  • cost of staff and their training (I imagine finding mootools programmers will be more difficult than these that slap jquery on their C.V / resume).
  • time (and cost) taken to maintain and extend your systems under each framework given your resources.

Both frameworks are great but I believe your interests are best served in staying with mootools.