Which Javascript Framework is the simplest and most powerful? [closed] - javascript

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I've been using various javascript frameworks including mootools, jquery, prototype and scriptaculous and have found them all good, but difficult to extend to more complex ideas.
If I am going to knuckle down and learn one, which is the simplest to extend and use whilst staying powerful enough to use in a variety of directions?

I propose jQuery.
I'll give you some of the major arguments from the presentation that my team put on yesterday for senior management to convince them of that.
Reasons:
Community acceptance. Look at this graph. It shows searches for "prototype", "yui" and "scriptaculous" growing from 2004 to 2008. Then out of nowhere in 2006 searches fro "jquery" shoot up to double the number of the other libraries. The community is actually converging on a single leading product, and it's jQuery.
jQuery is very very succinct and readable. I conducted an experiment in which I took existing code (selected at random) written in YUI, and tried re-writing it in jQuery. It was 1/4 as long in jQuery. That makes it 4 times as easy to write, and 4 times as easy to maintain.
jQuery integrates well with the rest of the web world. The use of CSS syntax as the key for selecting items is a brilliant trick which helps to meld together the highly diseparate worlds of HTML, CSS and JavaScript.
Documentation: jQuery has excellent documentation, with clear specifications and working examples of every method. It has excellent books (I recommend "jQuery in Action".) The only competitor which matches it is YUI.
Active user community: the Google group which is the main community discussion forum for Prototype has nearly 1000 members. The Google group for jQuery has 10 times as many members. And my personal experience is that the community tends to be helpful.
Easy learning curve. jQuery is easy to learn, even for people with experience as a designer, but no experience in coding.
Performance. Check out this, which is published by mootools. It compares the speed of different frameworks. jQuery is not always the VERY fastest, but it is quite good on every test.
Plays well with others: jQuery's noConflict mode and the core library's small size help it to work well in environments that are already using other libraries.
Designed to make JavaScript usable. Looping is a pain in JavaScript; jQuery works with set objects you almost never need to write the loop. JavaScript's greatest strength is that functions are first-class objects; jQuery makes extensive use of this feature.
Plug-ins. jQuery is designed to make it easy to write plugins. And there is an enormous community of people out there writing plugins. Anything you want is probably out there. Check out things like this or this for visual examples.
I hope you find this convincing!

In my opinion, jQuery is exceptionally powerful and simple. It uses CSS selector syntax to pull back elements and only adds two functions to the global namespace: jQuery() and $(), which is an alias for jQuery().
There are a massive number of plugins available for jQuery to let you do things like create slide shows, accordion controls, rich calendars, etc. The book "jQuery In Action" is a phenomenal companion to the online reference material.
We used it on my last project to create a fairly rich scheduling tool and we liked it so much, we're encouraging it's adoption throughout our consulting company as the defacto standard for all JavaScript use. You can check out the results at http://www.stanleysteemer.com

See also (other related questions):
Comparison of Javascript libraries
What JavaScript library would you choose for a new project and why?
What is the single most useful general purpose javascript library for rich internet apps?
Which JavaScript framework is best for web development?
Which JavaScript library is recommended for neat UI effects?
What is the best lightweight javascript framework?
Any good AJAX framework for Google App Engine apps?

jQuery is my favorite

Prototype. Is simple, unobtrusive, and makes your javascript code look cleaner than ever.
It has a wonderful user group, where you can get your questions answered almost immediately

Another vote for jQuery. It's small, focussed, and yet very powerful. It's also reasonable well documented, by the (generally awful) standards of JS libraries.
It's also very easy to extend, once you get your head around the syntax.

NOTE: This answer was pre-Angular/Ember/etc. so addresses an outdated issue.
I teach this stuff, and really had little choice but to home in on JQuery, since the majority in the industry has already 'chosen' it (not always a good reason, I know), but also because - for students that already know some CSS - the entry point is lower.
I've also used Mootools (my second choice), but a colleague convinced my to switch to JQuery with the 'programmability' argument - I find it cleaner to code with and understand. The JQuery community, online documentation, free online books and third-party sites help, too.

Related

Jquery or pure javascript [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
Would a JavaScript programmer, that knows JavaScript pretty well, write his/her code in JQuery or in pure JavaScript ?
In other words, is JQuery just for people who don't know JavaScript very well?
Lets say we are talking about creating "company presentation websites", where JavaScript mainly will be be used for animations.
jQuery isn't a separate programming language. It's a JavaScript library. Whether you use jQuery or not, it's still "pure JavaScript".
JavaScript is designed for both functional and object-oriented programming. And with any non-trivial application, a good programmer will likely make use of these tools to help write clean, maintainable, and efficient code.
When you group a set of functions/objects/types/etc. together that can be reused, you're creating a library—whether you give that library a name or not. Any good programmer knows to do this in order to reuse source code, provide convenience/utility functions, and avoid writing the same code over and over again for common tasks.
John Resig just happened to have created an excellent library for DOM manipulation that he's released under a generous open source license, and it's one that promotes a coding style many programmers enjoy, so it's become very popular.
I think it's safe to say that John Resig knows JavaScript pretty well, and he sure as hell uses jQuery. And if that doesn't reflect poorly on his programming abilities, then why should it reflect poorly on anyone else who uses jQuery?
Lastly, a good developer isn't defined by how much of the code in a project they wrote on their own. If you're a lonewolf hacker who likes to roll his own, that's fine. But the quality of a developer should be reflected by the quality of the end results they produce. If you build a CMS by yourself without using any pre-existing libraries or frameworks or collaborating with anyone, but it's all spaghetti code that exhibits tight coupling and violates DRY, then the fact that you wrote it all by yourself without the use of any pre-existing libraries means very little.
I think most clients would probably prefer you'd taken advantage of any off-the-shelf solutions that fit the job which could have helped complete the project in less time and produce better results.
In Jquery you write a lot less with the same effect (usually takes a little bit slower, but it does not bother anyone) ussualy without declaring temporary var`s.
Maybe otherwise for example:
$('a').click (function () {/* blabla */ }).css ({/* some css here */});
In pure javascript that one line can be presented by:
var links = document.getElementsByTagName("a") // in modern browsers = document.querySelectorAll("a");
for(var i =links.length; i--;){
var l = links[i];
l.addEventListener("click", function(){ //bla bla},true);
l.style.someCssAtrribute = 'someValue'
//etc
}
Although jQuery weighs around 100kb in return you write a lot less and more clearly
I like to think I know javascript well, but hated using it until I learned Jquery. With jquery I write code faster that is easier for others to read and easier to maintain. Why wouldn't you use it?
jQuery doesn't really help you with JavaScript as such - it helps you to work with things like DOM manipulation and events and Ajax requests. To write good software you still need a good understanding of the language but jQuery and other tools can help enormously in creating working applications.
So the answer to your question is "no, jQuery isn't just for people who don't know JavaScript".
The strength of jQuery is that it breaks down common needs into behaviors, where jQuery does the dirty work in figuring out how to best fulfill that request considering the current browser. This makes your code consistent and concise for all browsers. Furthermore, it allows you to affect the DOM using selectors, allowing you to manipulate elements with the same intention at once rather than one-by-one.
There is no meaning in finding the difference between Javascript and jQuery. jQuery is one of the most efficient libraries in Javascript and it makes things easier. But it is foolishness to say that jQuery is for those who don't know Javascript well. If you are an expert in Javascript you will be one of them who use jQuery efficiently. At the same time if you are a beginner in Javascript but believe that you know how to use jQuery well, I would suggest you to learn more Javascript because jQuery hides quite a lot of things from you and sometimes you might not be able to identify the mistakes you make - even a simple statement in jQuery might use a loop - so you should be careful when using jQuery. It is a matter of performance and efficiency, so if you want to write flawless code using jQuery, you should be knowing Javascript also, then only you will be able to make the most of it.

resource for javascript without jQuery

Is there any repository of code snippets, tutorials, whatever, that concentrates on pure JS, without the use of frameworks?
I first approached javascript through scriptalicious then jumped to jQuery. I am now a seasoned jQuery developer, and I've done quite a lot in jQuery throughout the years.
My problem is, I've almost never coded in pure JS. By the time I got advanced in coding in general (I mean, cross-language), my JS coding style relied already heavily on jQuery.
Plus, each time I research a solution for a problem, the first results (or pages of results) in google involve jQuery, or, more rarely, another Js framework. Which leads me to this problem: since I have developed a lot of custom plugins, some fairly complex, for jQuery, I am quite sure I do know a lot of JS. But I can't tell the difference!
So I decided that from now on, and as long as I feel the need, I am going to try to use pure JS, at least at the beginning of each project (leaving myself enough time to revert to good old jQueryScript if I get stuck). My problem is I am way too advanced to follow beginner's tutorials. I would like to know if any of you guys has a suggestion for a place to begin my training. Some website where I could learn advanced JS, without frameworks.
I actually think Resig's book, Pro Javascript Techniques would be a great fit. I read it a while ago and my memory of it was that he walked through a lot of the kinds of cross browser issues one can experience with Javascript and talks about how one could create code to help remediate those issues.
Ultimately that thinking is what jQuery is all about, but this book is not a jQuery book at all, more focused on JavaScript, approaching the same kinds of problems jQuery makes you not have to think about.
Might be a great fit for where you are, and it is by no means a beginner book.
http://www.amazon.com/Pro-JavaScript-Techniques-John-Resig/dp/1590597273/ref=sr_1_1?ie=UTF8&s=books&qid=1310240944&sr=8-1
If you want learn more about JavaScript in general and really master it, there are two books that I would recommend:
JavaScript: The Definitive Guide
JavaScript: The Good Parts
Both are excellent resources with great depth and cover fairly advanced topics.
If you would like to explore the possiblities of JS outside the browser and explore some cutting edge JS then take a look at the Node.js and CommonJS projects.
I recommend using this Google group:
http://groups.google.com/group/jsmentors

Is plain vanilla JavaScript better than using frameworks like jQuery or MooTools? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I am wondering if it is a good idea to rely on frameworks like jQuery or MooTools or should we just use plain JavaScript?
Apart from avoiding the re-invention of wheel, do they add any specific value?
Since the frameworks are open to the public, can there be possibility of exploitation of any security holes that might appear (of course, unintentionally :) ) in the frameworks?
Are there any other points that are to be considered when choosing a framework or otherwise?
Frameworks solve cross-browser bugs which normally would cost hours of your time, so you can focus on functionality instead of worrying about some edge case browser bug.. instead of wasting 4-5 hours solving a bug spend that time with your family.
Frameworks such as jQuery are pretty loaded with stuff like animation, selectors, html manipulation so there's usually some sort of functionality already built into the library, again saving you more time and the API makes it really easy to actually accomplish complex things.
Interpreters and browsers are only getting faster and faster so I don't particularly think it's a huge issue loading an entire library up. In addition thanks to Google et al we get very fast cdns and nowadays lots of sites are using the same exact URI to pull the script in, meaning there's a higher rate of the script getting cached and reused on another site.
Instead of every single web developer having their own library it's much more efficient having thousands of people concentrated to bettering a handful of libraries so cross-browser bugs get documented and fixed.
Competition is a good thing, the result of the slickspeed tests resulted in much faster selector engines such as Sizzle. Developers not having to worry about trivial DOM bugs means more complex libraries are created daily, which means entry-level developers have access to very powerful plugins.
As far as security, jQuery for example will detect if the browser is capable of parsing JSON natively and if so, rely on that. Usually any modern browser will have this, and it's much safer than eval... so jQuery strives to use the safer and more secure methods first. It will only use eval if there isnt a JSON.parse method available.
An important thing to remember in jQuery though is remembering you're still coding in Javascript. Usually people get too caught up in the sugar coated methods and wrapping everything in $, I think it's important to know you can still do this.href instead of $(this).attr('href') if you would like an absolutely normalized uri for example.
Do not downplay the importance of avoiding the re-invention of the wheel. You don't invent a new computer each time you want to write a new program.
But apart from that, JavaScript libraries provide better cross-browser support. This is extremely helpful, as a quick look at QuirksMode will demonstrate.
JavaScript frameworks make many things easier. Look at the jQuery documentation and you will see how easily it is do many fancy things.
JavaScript frameworks have been extended by many people, so there are many high quality jQuery plugins (for example — it's the framework I know the best) that you can use without having to write them yourself.
It is unlikely that JavaScript frameworks would introduce security holes, as they don't expose any more functionality than what you can do with plain JavaScript.
The frameworks provide a cross-browser-API for JavaScript, so most of the time they are very usefull even though they come with a little speed-loss. But the JS-Engines get fast almost every update so that's not really a problem.
There are also very many plugins for the frameworks so they not only provide an API but also new cross-browser-features.
But it depends on what you wanna do.
I don't give great weight to the "Open Source is extra-vulnerable to security issues" argument. I see benefit of many Good Guys reading the code and spotting such problems. If this were an issue then we'd need to discard Linux, Apache, MySql, and most of the Java libraries.
Frameworks generally save a very great deal of effort, I see them precisely as a pre-invented wheel. They don't need any other value.
It depends on what you're using JavaScript for. If you want to be able to show and hide panels, animate stuff, attach events to multiple elements, do Ajax, etc. then you need to consider cross-browser issues.
jQuery eliminates the need to think about cross-browser issues and allows some really neat functionality like the above and also modal dialogs, etc.
So it depends on what you want from JavaScript.
I have never used MooTools so can't comment on that, but jQuery makes a lot of things easier.
Selecting collections of objects by class, name, partial Id, etc.
Simplify Ajax calls.
Wireup event handlers to handle onclick, mouseover, mouseout, etc. and assign to elements based upon general selectors so that the logic can be reused.
Tons of transitions and other visual stuff to pretty up the front end.
There are a lot more, but it generally simplifies/accelerates development. One thing to watch out for is if you are using a ton of selectors in a single function (loop that iterates over the DOM 40+ times) it is waaay more efficient to use vanilla JavaScript.
So my advise would be to code the front end with the aid of a framework and then optimize the underperforming parts by subing in vanilla JavaScript.
Also, I don't see how jQuery or MooTools could be a security threat as they are client side frameworks, not server side. Remember to always validate inputs on the server side in addition to any client side validation and to properly parameterize SQL queries that are constructed on the server side.

Learning JavaScript... Should I skip straight to the good stuff (the frameworks)?

I learnt HTML/CSS a good few years back, then PHP a little later. I've recently become interesting in web development again, just started playing with frameworks like Django and RoR. I'm curious as to how much time/effort I should spend learning straight JS before looking at frameworks. I've been reading through a let of articles called Mastering AJAX by Brett McLaughlin which seems quite good, but I'm seeing a lot of stuff (such as cross browser compatibility - even for things like XMLHttpRequest) coming up which look like they would be non-issues if using a framework.
So, should I keep reading through these articles and try to build stuff using basic JS, or should I just start looking into jQuery and the like?
Also, I've been watching a few videos regarding GWT from Google I/O. I've been learning Java over the last year, built a few medium sized apps in it. I'm wondering if GWT is something that's worth going straight to, along with gQuery?
Starting with the basics of JavaScript is a good idea, IMHO.
Read JavaScript: The Good Parts, by Douglas Crockford. Very, very good book.
You should also check out Douglas Crockford's web site.
I also had to come back here and mention this in an update:
Douglas Crockford presented an illuminating talk about JavaScript - past, present, future - at the Microsoft MIX10 conference earlier this year. You'll find the full video for Crockford's talk at Microsoft MIX10 - The Tale of JavaScript. I Mean ECMAScript.
No.
Just as when you are learning to program you are taught first C/Pascal then Java/C++ and finally Python/Ruby/Smalltalk/Lisp, and when learning any language you start with simple language constructs, you should first learn ECMAScript, then learn DOM and finally frameworks.
Why? Because you'll have a deeper understanding of the language, and will be able to debug things that might seem odd unless you've got that learning experience.
If you are a seasoned developer, you can speed up each phase, but don't skip them, or you will have problems due to not fully understanding the small oddities.
Javascript is an interesting and fun language, but can act rather odd at times (Date has bitten me a couple of times in the ass).
Use frameworks to avoid repetitive tasks and to simplify your code, but not as a starting point. Simplicity is a final goal, not the starting point, and frameworks are for that, simplicity, not for learning a language. Frameworks are intended for simplifying things for experienced developers.
Learning the differences between browsers (DOM implementations) will allow you to debug your framework. That is priceless.
I've been learning Java over the last
year...
Javascript is not Java. Never was never will.
Even if you can compile to Javascript from Java, it's still a framework, don't jump into it unless you already know what you are doing.
I think "both." Mix it up. Play around with a framework. You'll get stuck when you try to do something real, so you'll pick up some JavaScript to figure it out.
A lot of the good jQuery books teach you JavaScript along the way.
This is one of the best videos for beginner javascript developers that understand how to program in other languages:
It's a talk the John Resig did last year at Northeastern, most of it is devoted to talking about core javascript, then the last quarter of the talk jumps into jQuery:
http://video.google.com/videoplay?docid=-7485992465859932389&ei=jhZUSu73OpfSrQLgyYV3&q=john+resig&hl=en
It's actually a really interesting tech talk and presentation since he does live examples and Resig is pretty good at presenting.
Like others in this question, I also highly recommend reading Javascript: The Good Parts for a better understanding.
Yes, jumping straight to framework-based programming instead of DOM is a good idea.
I started doing JS before any major frameworks like jQuery came along, and was reluctant to switch at first, but when I first started using jQuery, it felt so good to be able to write selectors and stuff and not have to worry about cross-browser compatibility.
However, there are some areas of JS where frameworks wouldn't be available. One of them is in userscripting, where you have to make your script work on a site you don't control. Another such one is the use of JavaScript in applications such as XUL.
Overall, I suggest you start with some trivial JS applications, then switch to jQuery instead of going on to the complex topic of DOM.
What makes you think that the frameworks are the good stuff and the JavaScript is not?
If you ask me, I will say that JavaScript is a real fun language and you should learn it first. JavaScript has received bad rap because it was mainly used for browser scripting and those browsers were buggy making people think that JavaScript sucks.
Crockford says that JavaScript is the world's most misunderstood language.
If your prior experience is with PHP (or any non functional language for that matter), the concept of 'first class functions' will really give you an 'aha' moment. 'Closure' will be another tool which will simplify your code and will make you wonder why all languages don't have it. Prototype inheritance will show you that there are alternatives to OOP. I would definitely suggest that you learn JavaScript first before you jump to any frameworks. I must add that you will also have to learn the concepts (first class functions/closure/prototype inheritance), to use any JS framework efficiently as all frameworks exploit the features of JavaScript.
To learn JavaScript, get Crockford's 'JavaScript, The Good Parts' book and try to learn the language using a standards compliant browser (say Firefox [with FireBug], Safari, Chrome) without focusing on DOM manipulation. This presentation by Simon Wilson is also good.
Once you have a good feel for the language, move on to the next step i.e. manipulating the DOM. I would personally suggest that you try to do some DOM manipulation using bare bone JavaScript to get better understanding of the DOM and the pain points involved. [E.g., when I attach a method to onClick of event, 'this' doesn't refer to what I think it refers to?]
After you have suffered a little bit of pain by doing DOM manipulation by hand, move on to a JavaScript framework which removes all the pain and makes JavaScript fun again. Personally, I would highly recommend jQuery over other frameworks.
And if you have any questions while on your JavaScript journey, you can always ask them on SO! :) Good luck.
I wouldn't touch any framework in any language until I have good basic understanding of underlying technology. Worth type of coder is one that uses tool without a knowledge.
JavaScript has somewhat sad history but in its latest incarnation it's surprisingly powerful and even fascinating language. I say - learn it well, then use whatever framework suits your current needs
It depends on where you want to invest your time. Ideally, we're all expert in assembly language, but that's not realistic or practical. We have to pick our battles. Then generally we attack each other for picking the wrong battle, which we call "cargo cult coding."
Personally, out of all the things I could spend a lot of time banging my head against, the intricacies of cross-platform JavaScript seemed less interesting and rewarding than other choices, so I decided to jump straight to jQuery. I'm happy with how it worked out.
I had the same background as you. After 6 months of MooTools I found out that mootools was indirectly teaching me "vanilla" javascript.
I've heard people say that mootools feels more like plain ol' javascript than jquery (after all, jquery's tagline is "jQuery is designed to change the way that you write JavaScript.").
I'd recommend starting with a framework. Plenty of the best javascript developers use frameworks. Once you're comfortable there you'll likely be able to pick up the others frameworks and plain ol' javascript quite readily.

Why is jQuery so widely adopted versus other Javascript frameworks? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
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 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.
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.
I've been asking myself this very same question for a while now, by means of just trying to wrap my head around the argument. And with ever discussion I read, the overwhelming response has been "More widely adopted - therefore better".
I am one who uses both extensively. JQuery at work (adopted because it was "more widely adopted") and Mootools on personal projects. As a result, I constantly find myself feeling crippled when using JQuery; Be it with JSON support, element creation, event handling... and so on. At work, I find myself writing chains 75 events long... and I feel dirty as a result.
My main overall beef with JQuery though, is that there's a lack of consistency or practice where plug-ins and 3rd party developers are concerned. The anecdotal "More plug-ins are available" really doesn't help me when there's no consistency between the plug-ins, structurally or otherwise. It took me several weeks to learn the "accepted" plug-in model, and even then, I've adapted my own pragmatic style into it, as I find error and inefficiency within the current structures. It can be said that it's a 'Pro' that anyone can jump in and start JQuerying it up. However, I am more inclined to call that a 'Con', in that you will see 30 different ways to accomplish something, and it's difficult to pin an accepted standard.
So what does it mean to "Know JQuery", Does it mean you know how to rock a little .hide().show().fadeIn().fadeOut()?
When I have to get gangster on my JS at work, I miss me some Mootools. I mean no Native JSON support? C'mon......
In response to the "Widely adopted" response, we all know OSCommerce is the most "Widely Adopted" shopping cart, and we all know what a pile of shit that is. I'm in no way comparing JQuery to OSCommerce. I'm simply pointing out the faulty of "Widely Adopted" response.
As for plugins, the App store for apple has what... 100k apps? 50,000 are fart apps. Sure there's a lot of plugins to JQuery, but the ratio of trash to worth-while is great.
jQuery gives you access to crisp and concise functional programming methods. Since the release of method chaining in (LINQ) in C# 3.0 this works very well for .NET programmers. So the flow from one language to the next is easy. To be able to query the DOM for an object, or a list of objects, works much better for us. It is jQuery's selection power first that makes it so attractive, then the extendability of it, and of course all the built in features that come with it are nice. Also, the community behind is wonderful in that I first look to see if someone else did something and then attempt to do it myself if a solution was not found. And last...but certainly not least...the fact that Microsoft is going to include in in Visual Studio 10 and support it is great. Moo Tools, Prototype, etc. just can't compete with all of the above.
JS frameworks are so much alike, anyway. If you've been working with mootools for some time, stick to it. Knowing your framework is much more important than choosing one because of this or that.
In my opinion, mootools is better for advanced javascript programmers, while jquery is better for non-javascript programmers. That's what I think after reading both documentations, mind you, I didn't use any of them. jQuery lacks support for the core of javascript, function binding, object cloning, thread stacking, to name a few.
jQuery, like any framework, does what it does and if it doesn't fit your needs you should use something else. I don't use jQuery to do complicated programming in javascript, I use it because it makes DOM manipulation and CSS3 style stuff simple and 95% of the time that is what I need.
I have not looked at MooTools in a while either. But here are my points for JQuery:
Consistent programming model (there is a JQuery way that works)
Excellent documentation. When I started JQuery had the best documentation out there.
Extensive 3rd party plugings
Microsoft support -- I am an asp.net developer, this helps ease clients minds. Plus it ships with my tools now.
Lots of getting started guides.
JQuery's website looks nicer than MooTool's web site. I'm sorry that matters, but it does. Remember, many of these tools need to appeal to designers as well as developers.
YAGNI.
Yes, it's kinda out of place here, but that's the main reason jQuery has a larger base than MooTools. All those extras MooTools brings to the table are nice, but YAGNI.
It's not about best, it's about satisficing -- finding the adequate solution to the problem at hand. jQuery is easy to use, its primary aim is DOM manipulation. Since 95% of the people picking up javascript are doing so just to manipulate the DOM, there's no point in going through the longer MooTools learning curve. MooTools simply doesn't bring anything to the table for them that jQuery doesn't deliver with less effort.
MooTools demands more from you before you use it, jQuery lets you throw something together quickly. If you start writing large, heavy-duty js apps, you might run into some of the drawbacks of that approach, but again 95% of the folks writing js don't do that, so those things don't matter to them. They use a server-side language for the heavy-lifting and javascript for the DOM.
For that matter, they may not matter to your team, either. To take you through the lists, point by point (jQuery first):
Large community of supporters -- only slightly relevant to the project. Of more relevance to the team personally, because it speaks to life after you. If misfortune strikes (please, God, no) and your firm is gone, jQuery gets them more jobs than MooTools.
Plugin Repository -- very relevant, as it helps keep from reinventing the wheel.
Integration with Microsoft's ASP.NET and VisualStudio -- very relevant if you're a .NET shop. In fact, this alone should be the reason to switch if you do .NET.
Used by Microsoft, Google and others -- who cares?
Now for the MooTools list:
Object Oriented Framework with Classic OOP emulation for JS -- irrelevant, unless the nature of your projects makes that a plus. I don't know what you're building, but for web shops, this is only rarely relevant. Most web shops don't have enough code to make this a plus.
Extended native objects -- again irrelevant for most web shops
Higher consistency between browsers for native functions support. -- Relevant
More easy code reuse -- This conflicts a little with the jQuery advantage of a large repository. A large repository by itself speaks to reusing code. I suspect you're using a narrow definition of code reuse, here, that may not be relevant. I've reused a lot of the jQuery code I've built, as well as MT code.
Used by The World Wide Web Consortium, Palm and others. -- Irrelevant. The only relevance about who else is using what is if you're wanting a job there. There's more relevance in how many shops use it than in any particular shop using it.
There is no One True Way to approach javascript coding. Get your bias out of the way, and sit down with your team and get their bias out of the way as well. Talk turkey about the specific types of projects you're undertaking (and want to undertake) and the strengths of each library as applied to those cases. (How they might handle other cases doesn't matter, because those other cases don't exist.) You should arrive at a consensus from that.
(YAGNI = You Ain't Gonna Need It, if I need to explain it.)
I choose to use jQuery as our default UI library precisely because it does not extend or otherwise monkeypatch native objects, unlike prototype.js or mootools. Kick in the documentation angle and there really is no question as to which framework to use.
You kinda say it yourself:
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.
Most of the extra stuff that MooTools does is stuff that we just don't need.
As you say yourself jQuery is easier to learn, which is actually more important for most people when choosing a framework.
What I DON'T need in JavaScript is definetely OOP and some ugly object emulation.
Last time I checked MooTools (maybe 1,5 years ago :-), it had browser incompatibilities with manipulating multiple select.
So jQuery is completely looks OK to me.
Not only is jQuery a nice library, but its creator, John Resig, also has some street cred as the author of Pro Javascript Techniques.
We have 2-3 copies of this book around our office.
jQuery is small (intentionally so) but can have functionality added to it through plugins.
The thing that made my experience with mootools a rather unpleasant one was the documentation and the stability of the API:
I simply wasn't able to find a documentation that related to the mootools-Version in use. Won't be that much of a problem if the API defined was stable. But due to some functions that disappeared in the newer Version (a ChangeLog was found after hours of searching) a migration wasn't possible either. After that, mootools was out of the race for me.
Like many others, I don't want to introduce class-based OOP into simple user-interface manipulations. Thats what I use jQuery for: not so complicated user-interface stuff.
When I have to build rich browser-side applications, I'd always switch to the big solutions (ExtJS, YUI, qooxdoo) that offer a variety of ready to use widgets.
Larger User Community and more wide-spread adoption makes a big difference when comparing tools/libraries that offer similar functionality and concepts. Larger community means more support, more examples, more good ideas, and more reusable code snippets, which is especially important when you're working on a rare scenario -- more likely someone else has encountered it before.
Secondly, in benchmarks I've seen, jQuery is faster than MooTools.
I also really like their emphasis on keeping a small core and adding functionality through plugins. Prevents the core library from getting really big and unwieldy.
I've never used MooTools personally but I have no doubt that its a fantastic library that offers some acceptable equivalent to most any jQuery feature or concept, but point #1 takes the cake for me.
Another reason: It's easier to sell jquery to management. Doing internal, asp.net based developement in a corporate environment the magic words are "it's supported by Visual Studio".
For one thing, that's not all it does. There are quite a few other features as well. For another, not everyone uses it. But I don't want to interrupt a good rant.
I have to second a lot of the answers...great documentation and community support is crucial. I used to hate js programming and would avoid it like the plauge, but now I've completely embraced it because of jquery and the quick learning curve.
It's not always about who has the best technology!
Mootools, does not function properly or does not function at all when using jquery prototype etc. Agreed there is absolutely no reason to use them simultaneously, but once in a while they do land up on the same page (ex. plugins, slideshows, widgets etc) and things stop working.
That in itself is unacceptable. So all props for jquery to not create unnecessary headaches!
Why did people start using fax machines? At a certain point the benefit increases exponentially.

Categories