This post originated from an RSS feed registered with Web Buzz
by Stuart Langridge.
Original Post: Not blocking the UI in tight JavaScript loops
Feed Title: as days pass by
Feed URL: http://feeds.feedburner.com/kryogenix
Feed Description: scratched tallies on the prison wall
Everyone’s written a JavaScript loop that just loops over all the {LIs, links, divs} on a page*, and it’s pretty standard. Something like
var lis = document.getElementsByTagName("li");
for (var i=0; i<lis.length; i++) { // yes this could be more efficient, don't care
// do something here to lis[i]
};
or, if you’re using jQuery:
$("li").each(function() {
// do [...]