10 November 2009 0 Comments

jQuery Optimization : Avoid Unnecessary Selector

Common subexpression elimination is a common way to optimize any programming code. Doing unnecessary selector is expensive. Doing something like this:
jQuery(’.class’).each(function(){
jQuery(this).html();
jQuery(this).find(’div’).each(function(){
//etc.
});
});
which required many selector it is best to use 1 instead since we are repeating ourselves and doing some redundant selector.
jQuery(’.class’).each(function(){
var obj = jQuery(this);
obj.html();
obj.find(’div’).each(function(){
//etc.
});
});
This is something that we often see in many plugin. Many plugin [...]

Get Adobe Flash playerPlugin by wpburn.com wordpress themes