As mentioned in the new features in MooTools More in 1.2.4.1, there's a new plugin called Depender which uses MooTools dependency mappings to allow you to lazy load additional scripts on the fly based on what you need. Rather than list every single file you depend on, you just list the features you want to use and it computes all the specific files needed and each of the files that they need (and so on), excludes the files you already have, and then injects the remaining scripts into the document, providing a callback.
Unfortunately this method is rather slow. The JavaScript plugin must inject each individual script in the dependency list and all these requests can only go as fast as your browser can make them. As a companion to this plugin, we have also authored a stand alone server side application.
The new server-side depender companion app ships in two forms: a PHP version and a Django version. They each have their own positives and negatives. The PHP version ships with a web-based interface — a builder you can use to check off the things you want in your download (similar to what you see on MooTools.net). On the other hand, the Django version is faster. The Django app caches everything to memory but the PHP version caches results to disk.
Depending on your needs, you can also use these server-side applications to lazy load chunks of functionality on the fly. This obviously requires your application to talk directly to the server when it needs more code. These apps aren't designed for enterprise scale.
The server side applications are available on github. We still consider the state of this project to be beta, but we want to get the tools into your hands now. If you have any feedback or find any bugs, we want to hear about it. Check out the documentation to see how it all works, including the Depender Client(docs), which gives you this nifty interface:
Depender.require({
scripts: ['DatePicker', 'Logger'], //array or single string for one item
callback: function() {
//your code that needs DatePicker and Logger
}
});
//later, you need to load more dependencies...
Depender.require({
scripts: 'Fx.Reveal', //array or single string for one item
callback: function(){
//if, for some reason, Fx.Reveal is available already,
//then this function will execute immediately, otherwise it will
//wait for the requirements to load
$('someElement').reveal();
}
});
Libraries that you download with Depender will all have a standard header that looks something like this:
//MooTools, <https://mootools.net>, My Object Oriented (JavaScript) Tools. Copyright (c) 2006-2009 Valerio Proietti, <https://github.com/kamicane>, MIT Style License.
//MooTools More, <https://mootools.net/more>. Copyright (c) 2006-2009 Aaron Newton <http://clientcide.com/>, Valerio Proietti <https://github.com/kamicane> & the MooTools team <https://mootools.net/developers>, MIT Style License.
//Contents: Core, Browser, Array, Function, Number, String, Hash, Event, Class, Class.Extras, Element, Element.Event, Element.Style, Element.Dimensions, Selectors, DomReady, JSON, Cookie, Swiff, Fx, Fx.CSS, Fx.Tween, Fx.Morph, Fx.Transitions, Request, Request.HTML, Request.JSON, More, Element.Shortcuts, Element.Measure, Fx.Reveal
//This lib: http://clientcide.com/js/build.php?requireLibs=mootools-core&require=Fx.Reveal&compression=none
This header includes, among other things, a manifest of the contents of the file and a url that can be used to retrieve it again. This is especially useful if you want to come and download the file again for the latest version.
The builder on MooTools.net does not use Depender yet but we will deploy it there soon. You can see it live on the Clientcide builder.
The foundation of every great open source project is its community. The MooTools Team creates the base framework code but it’s all of you that take the framework and build outstanding plugins. Here are some great plugins and tutorials that have been released recently.
MooShell, created by Piotr Zalewa
(zalun)
, is the best code pasting tool since Pastebin. MooShell allows you to paste your HTML, CSS, and MooTools javascript into the page and test. MooShell is an excellent utility for troubleshooting an issue or demonstrating your code.
MooTools contributor Mark Obcena keeto
continued his excellent series of "Up the Moo Herd" tutorials with "There's a Class For This." This post discusses Class Mutators, Mixins, and MooTools' inheritance model. Consider this post a must-read for novice and expert MooTools developers.
http://keetology.com/blog/2009/10/27/up-the-moo-herd-iv-theres-a-class-for-this
MooRTE is a great MooTools rich text editor. MooRTE is lightweight, customizable, and very easily skinnable. Try MooRTE out in your CMS!
http://siteroller.net/projects/moorte/
Remember to upgrade your MooTools 1.1 and MooTools 1.2 builds to 1.1.2 and 1.2.4 respectively. Firefox 3.6 has removed document.getBoxObjectFor which will impact Gecko detection.
/blog/2009/11/02/upgrade-mootools/
These are just a few of the great MooTools plugins floating around the MooTools community recently. Keep up the good work and we look forward to featuring your plugins in future posts!