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 [...]

10 November 2009 0 Comments

jQuery Optimization : Balance between JavaScript and jQuery

jQuery is excellent to speed up ANY front-end developer job. However, there are times when jQuery may take more time to perform certain action than using JavaScript. For example,
css: function( key, value ) {
// ignore negative width and height values
if ( (key == ‘width’ || key == ‘height’) && parseFloat(value) < 0 )
value = undefined;
return [...]

9 November 2009 2 Comments

jQuery Optimization : Avoid Unnecessary Styling

This is another common mistake that many jQuery developer made. jQuery provides us with the ability to manipulate styling through styling methods. Although it is very convenient to do that but it also contribute to the size of the script and makes maintenance difficult. Furthermore, some of the selector is made solely for styling purposes [...]

9 November 2009 0 Comments

jQuery Optimization : Optimize Selector

We can also optimize our selector other than being a bit specific on our selector. The key to optimize our selector is simple. Naive JavaScript provides two method to get id and tag (getElementById and getElementByTagName). Hence, it is always faster to use tag or id on your selector. No matter what algorithm used for [...]

Get Adobe Flash playerPlugin by wpburn.com wordpress themes