After some Googling, I discovered that there are many alternatives to jQuery and there is some debate in the developing world over which library is optimal. Here are a few alternatives to jQuery I found particularly interesting, with a specific focus on one of jQuery’s biggest rivals, MooTools.
Let’s take a closer look at how this works. To make a class in MooTools, you pass an object to the Class constructor. That object then becomes the prototype for every instance of the class. Here’s how we would create a new Animal class that initializes each animal with an age.
1 2 3 4 5
So now we have an Animal class. But what if we want to create a new version of an animal that has additional properties? We can use the “Extends” functionality of MooTools to create a subclass that has access to all of the properties and functionality of the parent object, Animal, but won’t affect the base class at all.
1 2 3 4 5 6 7 8
Now we can create a new instance of a cat that will have the properties name (from the base class, Animal) and age (from the subclass, Cat).
1 2 3
As you can see, this code reads more like a pure object-oriented programming language.
This approach makes reusing code easy in MooTools. Anytime you want to define a pattern, you can use these Class constructors. jQuery on the other hand, does not give you a system for extending instances into subclasses.
So now that we understand the primary difference between the two libraries, how can we conclude which one to use?
If your goal is solely to interact with the DOM quickly and easily, jQuery is likely all you need. It’s simple to use and very effective, which explains why thousands of programmers swear by it and it is present on millions of webpages. The large and active community means it’s easy to find great support and documentation.
When it comes down to it, MooTools and jQuery can be used in different ways to achieve entirely different things. You should decide which library to use based on what tasks you are trying to accomplish – and if you like some aspects of both, there’s no reason why you cannot use both libraries. After all, you’re a developer – you have endless tools at your disposable to utilize how you please.
“Dojo saves you time, delivers powerful performance, and scales with your development process. It’s the toolkit experienced developers turn to for building superior desktop and mobile web experiences.” (Dojo documentation)
Dojo is a much larger library than jQuery. Like MooTools, it offers solutions for object-oriented programming. It also provides a large collection of user-interface widgets. It is often criticized for its incomplete and unorganized documentation.
“Prototype takes the complexity out of client-side web programming. Built to solve real-world problems, it adds useful extensions to the browser scripting environment and provides elegant APIs around the clumsy interfaces of Ajax and the Document Object Model.” (Prototype documentation)
Like the aforementioned libraries, Ext JS provides a class-based system. Ext JS is similar to Dojo in that it provides a comprehensive collection of customizable UI widgets, as well as charting and grid packages that allow you to visually represent data in a number of ways. Ext JS is commercially licensed, meaning it comes at a price.
Definitely read Aaron Newton’s post jQuery vs MooTools for a much more detailed analysis of the two libraries: http://www.jqueryvsmootools.com
JScripter.com on Popular jQuery Alternatives: http://www.jscripters.com/popular-jquery-alternatives/