MooTools (My Object-Oriented Tools) is a lightweight, object-oriented JavaScript framework. It is released under the free, open-source MIT License.
Overview
MooTools provides the user with a number of options beyond native JavaScript. These include:
- An extensible and modular framework allowing developers to choose their own customized combination of components.3
- MooTools follows object-oriented practices and the DRY principle.4
- An advanced effects component, with optimized transitions such as easing equations used by many Flash developers.5
- Enhancements to the DOM, enabling developers to easily add, modify, select, and delete DOM elements. Storing and retrieving information with Element storage is also supported.6
The framework includes built-in functions for manipulation of CSS, DOM elements, native JavaScript objects, Ajax requests, DOM effects, and more. MooTools also provides a detailed, coherent application programming interface (API),7 as well as a custom downloads module allowing developers to download only the modules and dependencies they need for a particular app.89
History
Valerio Proietti first authored the framework and released it in September 200610 taking as his inspiration Prototype and Dean Edward's base2. MooTools originated from Moo.fx, a popular JavaScript effects library released in October 2005 by Valerio Proietti as an add-on to the Prototype Javascript Framework.11 It can be used as a lighter alternative to script.aculo.us or other, bigger libraries. It provides simple, basic effects, and guarantees a small library size.
Whereas Prototype extended—prototyped—many of JavaScript's native String, Array, and Function objects with additional methods, Proietti desired a framework that (at the time)12 further extended the native Element object as well13 to offer greater control of the Document Object Model (DOM).14
Components
MooTools includes a number of components, but not all need to be loaded for each application. Some of the component categories are:
- Core: A collection of utility functions that all the other components require.15
- More: An official collection of add-ons that extend the Core and provide enhanced functionality.16
- Class: The base library for Class object instantiation.17
- Natives: A collection of JavaScript Native Object enhancements. The Natives add functionality, compatibility, and new methods that simplify coding.
- Element: Contains a large number of enhancements and compatibility standardization to the HTML Element object.18
- Fx: An advanced effects-API to animate page elements.19
- Request: Includes XHR interface, Cookie, JSON, and HTML retrieval-specific tools for developers to exploit.20
- Window: Provides a cross-browser interface to client-specific information, such as the dimensions of the window.21
Browser compatibility
MooTools is compatible and tested with:22
- Safari 3+
- Internet Explorer 6+
- Mozilla Firefox 2+
- Opera 9+
- Chrome 4+
Emphasis on modularity and reusability
Every JavaScript framework has its philosophy, and MooTools is interested in taking full advantage of the flexibility and power of JavaScript in a way that emphasizes greater modularity and code reuse. MooTools accomplishes these goals intuitively to a developer coming from a class-based inheritance language like Java with the MooTools Class object.
Class is an object of key/value pairs containing either properties or methods (functions). Class is effortlessly mixed and extended with other Class instantiations allowing for the most excellent focus of MooTools: Code reuse achieved through maximizing the power of JavaScript's prototypical inheritance but in a Class object syntax more familiar to classical inheritance models.23
Object-oriented programming
MooTools contains a robust Class creation and inheritance system that resembles most classically based Object-oriented programming languages. For example, the following is MooTools' equivalent of the examples in Wikipedia's polymorphism page:
var Animal = new Class({ initialize: function(name) { this.name = name; } }); var Cat = new Class({ Extends: Animal, talk: function() { return 'Meow!'; } }); var Dog = new Class({ Extends: Animal, talk: function() { return 'Arf! Arf!'; } }); var animals = { a: new Cat('Missy'), b: new Cat('Mr. Bojangles'), c: new Dog('Lassie') }; Object.each(animals, function(animal) { alert(animal.name + ': ' + animal.talk()); }); // alerts the following: // // Missy: Meow! // Mr. Bojangles: Meow! // Lassie: Arf! Arf!See also
- Free and open-source software portal
- Ajax framework
- Rich Internet application
- Web 2.0
- Comparison of JavaScript frameworks
- XMLHttpRequest
- JavaScript framework
- JavaScript library
Further reading
- "The Introduction to MooTools Architecture". Applied Mechanics and Materials.
- "Interactive Consultation Based on MooTools Long Polling Techniques". Applied Mechanics and Materials.
- Orchard, Leslie M.; Pehlivanian, Ara; Koon, Scott; Jones, Harley (August 31, 2009). Professional JavaScript Frameworks: Prototype, YUI, ExtJS, Dojo and MooTools (1st ed.). Wrox Press. p. 888. ISBN 978-0-470-38459-6.
- Newton, Aaron (September 18, 2008). MooTools Essentials: The Official MooTools Reference for JavaScript and Ajax Development (1st ed.). Apress. p. 300. ISBN 978-1-4302-0983-6.
- Lecomte, Xavier (June 1, 2012). Découvrez MooTools : Un framework JavaScript pour un site dynamique et interactif (FR) (1st ed.). DigitBooks. p. 260. ISBN 978-2-8150-0215-8.
External links
References
"MooTools at FOSDEM slides" (PDF). Archived from the original (PDF) on 2011-07-23. Retrieved 2010-02-17. https://web.archive.org/web/20110723055127/http://cpojer.net/Talks/MooToolsFOSDEM.pdf ↩
The Official MooTools Website http://mootools.net ↩
MooTools' Core Download Page http://mootools.net/core ↩
MooTools Class Object Archived 2008-08-31 at the Wayback Machine http://docs.mootools.net/Class/Class ↩
MooTools' Effects (FX) Class Archived 2008-06-23 at the Wayback Machine http://docs.mootools.net/Fx/Fx ↩
MooTools' Element Class - A comprehensive list of Element manipulation methods. Archived 2008-09-05 at the Wayback Machine http://docs.mootools.net/Element/Element ↩
A Better Way to Use Elements http://mootools.net/blog/2010/03/19/a-better-way-to-use-elements/ ↩
MooTools Core Builder http://mootools.net/core ↩
MooTools More Builder http://mootools.net/more ↩
Newton, Aaron (September 18, 2008). MooTools Essentials: The Official MooTools Reference for JavaScript and Ajax Development (1st ed.). Apress. pp. xvi. ISBN 978-1-4302-0983-6. 978-1-4302-0983-6 ↩
Newton, Aaron (September 18, 2008). MooTools Essentials: The Official MooTools Reference for JavaScript and Ajax Development (1st ed.). Apress. pp. xv. ISBN 978-1-4302-0983-6. 978-1-4302-0983-6 ↩
Version 1.6.1 of Prototype includes "an element metadata storage system." Prototype 1.6.1 released Archived 2010-03-01 at archive.today by Sam Stephenson, written September 1st, 2009. Retrieved March 21, 2010. http://www.prototypejs.org/2009/9/1/prototype-1-6-1-released ↩
Newton, Aaron (September 18, 2008). MooTools Essentials: The Official MooTools Reference for JavaScript and Ajax Development (1st ed.). Apress. pp. xvi. ISBN 978-1-4302-0983-6. 978-1-4302-0983-6 ↩
Note that MooTools does not extend the native Object—all JavaScript primitives like String and Function inherit from it—but instead provides a convenient Hash for the purpose: Think of it like having a set of utility methods that allow for nearly effortless object manipulation of regular JavaScript objects that are otherwise unaffected by the process. (Newton, Aaron (September 18, 2008). MooTools Essentials: The Official MooTools Reference for JavaScript and Ajax Development (1st ed.). Apress. pp. xvi. ISBN 978-1-4302-0983-6.) 978-1-4302-0983-6 ↩
MooTools Core Archived 2009-10-02 at the Wayback Machine http://mootools.net/docs/core ↩
MooTools More Archived 2009-10-04 at the Wayback Machine http://mootools.net/docs/more ↩
MooTools Class Archived 2008-08-31 at the Wayback Machine http://docs.mootools.net/Class/Class#Class ↩
MooTools Element Archived 2008-09-05 at the Wayback Machine http://docs.mootools.net/Element/Element ↩
MooTools Fx Class Archived 2008-06-23 at the Wayback Machine http://docs.mootools.net/Fx/Fx ↩
MooTools Request Class Archived 2008-07-30 at the Wayback Machine http://docs.mootools.net/Request/Request ↩
In addition to getting the size for any Element, you can easily get the dimensions of the window Archived 2008-09-11 at the Wayback Machine http://docs.mootools.net/Element/Element.Dimensions#Element:getSize ↩
MooTools lists its compatibility on its homepage. http://mootools.net/ ↩
jQuery versus Mootools http://jqueryvsmootools.com/ ↩