We’ve all seen people who do this:
jQuery('a').each(function(){
jQuery(this)[0].innerHTML += ' proccessed';
});
function letsPoluteNS() {
polute = '';
for (morePolution = 0; morePolution < arguments.length; morePolution++)
polute.join(arguments[morePolution]);
return polute;
}
and so on. I was wondering what people have seen the most common JavaScript/jQuery technique that is slowing down the page and/or wasting time for the JavaScript engine.
I know that this question may not seem to fit into what’s an accepted question, yet I’m asking “what is the most common accepted waste?”
I’m guilt of this. Basically using only the element’s class in a jQuery selector. Instead of combining the class selector with the elements tag name.
Instead of the quicker
Also this is inefficient, many people don’t make use of the context parameter for selectors
$( selector, [ context ] )
Which can be handled better like this: