jQuery Performance Tips
Posted: December 15th, 2011 | Author: Vincent | Filed under: JavaScript | No Comments »http://dumitruglavan.com/jquery-performance-tips-cheat-sheet/
Some notes from reddit:
#6 There is little to no performance difference between a cached selector and chaining. The ONLY difference would be shorter code (less bandwidth used?).
#9 This is just plain wrong. DOM manipulation can be extremely fast if you know what you are doing. He uses this example
The faster way to do this would be
frag = $('<ul id="menu"></ul>');
listItem = $('<li></li>')
for (var i = 1; i < 100; i++) {
frag.append(listItem.clone().text(i));
}
$('#header').prepend(frag);
#14 Use jQuery’s utility functions
“.each(), for example, relies on anonymous function calls. This can be REALLY slow”
#15 not really much of a performance tip
#16 is REALLY finicky and hard to profile.
Leave a Reply