MooTools

I use MooTools, a javascript framework that makes life so much easier for javascript developers. Maybe you've heard of JQuery, MooTools is like that, but a little different and slightly more stylish. For those of you who don't use MooTools or even JQuery, maybe it's time you started.

Before frameworks such as these, making dynamic pages was a nightmare. Even something as simple as smoothly changing an element's margin would require an if statement or two and a timer. Something along the lines of:

function changeMargin(element, target)
{
currentMargin = document.getElementById(element).style.margin;
marginLength = currentMargin.length;
currentMargin = currentMargin.slice(0, marginLength - 2);

if(currentMargin < target) currentMargin++;
else currentMargin--;

document.getElementById(element).style.margin = currentMargin + "px";
if(currentMargin != target) setTimeout("changeMargin(" + element + ", " + target + ");");
}

With MooTools, all that is required is one line.

$(element).tween("margin", target);

This ease of use extends to all areas of javascript, from AJAX to element selection. And MooTools is extremely well documented. So why not go ahead and give it a try. Setting up is easy, all that's required is including the MooTools file before you start your javascript. The only downside is that the file is a hundred or two kilobytes large, especially if you include the MooTools more files, so if you're trying to be lightweight, you might consider avoiding them after all.

 
10/12/2009