Pre-cache your for loops
While reading through the JavaScript Patterns book, I saw an item that totally stuck out as a crystal clear “duuhhh!!” moment. Why have I never seen/heard of that before and certainly why wasn’t I doing it regularly (and why hadn’t I thought of it to be honest).
Instead of doing this:
[sourcecode lang=”javascript”]
for(var i=0; i < $(‘someselector li’).length; i++){
//loop through each LI in a UL, or any collection
[Read More]