JavaScript loop performance
Robert Nyman, the original author of the perfect little JS library, DOMAssistant, has done a little loop speed test and has come to a very useful conclusion that saves a lot of processing time. Next time you do a for loop through an array, start by saving the array.length into a variable, and use that:
for (var i=0, il=divs.length; i
}
Why is this faster? Well, if we don’t use the variable il, and do the loop like (i=0; i

