Why is jQuery so widely adopted versus other Javascript frameworks?

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 )?


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

  • you are very familiar with mootools and take full advantage of its OOP model, making your code easier to manage and support already.
  • 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.
  • 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 CV / 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.


    Personally, jQuery does exactly what I need.

    I try to do most of my stuff in my server-side code, which is well structured: it has proper OOP, layers, and an MVC architecture. When I need to do something with Javascript, I have found (so far) that jQuery has what I need. Frankly, that falls into three categories:

  • Simple DOM manipulation , usually showing/hiding stuff without hitting the server.
  • Ajax calls , nuff said.
  • UI perks , including modal popups, animations, fading transitions from/to hidden/shown. I am a hardcore backend coding guy, and I suck at UI stuff. I really like that jQuery lets me programmatically make stuff that looks appealing.
  • On top of that, the jQuery plugin library is huge, and I've found quite a few libraries that simplify my client-side work. Good stuff.

    MooTools introduces OO thinking, which is nice, but not what I need. I want to keep my structuredness all on the backend, and not have to introduce that thinking to my client-side code. To me, client-side code is a very small piece of the emphasis and thinking about it from a Class-point-of-view is way overkill, and way more work. I feel like I'd be building two applications instead of one if I were to use what I'd think would be best practices for MooToools.

    I think that sums up why its so popular, especially around here. By and large, we're backend code-y type people, and jQuery lets us make an appealing UI programmatically, and lets us focus on our backend core.


    I'm not a fan of imposing classical object orientation onto JavaScript. There are so many ways to do it that one JavaScript Programmer might be using Base2 for OO, while another uses Prototype or Moo or JS.Class or Joose. Resig deliberately decided not to add classes to jQuery, and that has encouraged people to find more native JavaScript ways to solve problems.

    As a result, it's easier for me to read JavaScript other jQuery writers write, and to write jQuery code that's easier for others to read. I typically don't try to emulate class OOP in JavaScript. Instead, I create objects on the fly and pass them around, and I have lots of arrays of objects. It's so easy to understand that I've even found myself carrying that thinking over to OOP languages!

    For all I know Moo may very well have caught up with jQuery or surpassed it. But I can't spend my time tracking the 6 or 7 great JavaScript libraries to see which horse is ahead.

    I think it's was largely a matter of timing. When masses of programmers jumped into AJAX, jQuery was the hot new cool thing that solved their problems.

    Other libraries have largely caught up. YUI, ExtJS, Dojo, Moo--they're all great. But I can't use them all.

    I work hard enough trying to figure out the ramifications of the new features of the library I do use. For instance, jQuery added Live events as of 1.3. This actually let me cut code from many pages. Does Moo offer that now too, and how am I supposed to know it happened, if it did?

    I'm sure Moo is awesome. I'd love to have the time to learn it. But have you looked at Dojo? I had to use it on one project and found that it had pulled in most of the great ideas from jQuery as well. And it has pubsub and good support for Comet.

    I sympathize with you. But your programmers are talking sense. Learning jQuery is good for their careers, and there are more books, examples, and fellow programmers to ask for help if they use jQuery.

    If you decide to go jQuery after all, think hard before deciding whether to tack on an OO library. There are some cool ones (like JS.Class or Joose), but taking that step means isolating yourself from how most JavaScript programmers code.

    链接地址: http://www.djcxy.com/p/94012.html

    上一篇: OO JQuery和类

    下一篇: 为什么jQuery如此广泛地被采用与其他Javascript框架?