SyntaxHighlighter

Thursday, February 4, 2010

Performance Tips : Improving Web pages

Though we see broadband connections every where nowadays, according to statistics only 6.51% of total Indian internet users use broadband connection. Story is not different in US too, where almost 25% of population still not using internet at all and nearly 60% have broadband connections while rest internet users still rely on dial up connections , for more details please visit
[http://www.internetworldstats.com/stats.htm]

As a application developer , what I can do to minimize pains of slow internet, is nothing but develop a application which is optimum on performance, loads quickly.

Below are few of tips for Web application developer , how to go about this

1.Adopt strict XHTML coding practices for faster download of webpages & parsing.

2. Don't use images to represent text [Unlike fonts , where you have little control over the way they appear in different browsers, images always appear exactly how you design them, But this is not an excuse to use images in place of text]

3.Cookies might be small files,but browsers will need to download them. Large cookies take longer to download, which in turn increase the time the browser takes to load pages.

4.Don't include(inline script) javascript code in web pages,externalize wherever possible.
Because externalized files gets cached by browser, whereas javascript coded inline in a web page gets loaded along with HTML.

5.If Possible avoid tables, If still you do, explicitly specify the widths and heights of the tablecells,rows & columns, otherwise , browser have to perform many operations to calculate how to display them, which may slow down web page loading

6.Instead of developing bulky and heavy web page with lot of contents,prefer small and less bulky pages. (Divide pages into small pages..)

7.Compress & minify Javascript files. Java script files can be quite impressive in size,which means there download times can exceed that of all other components combined.
One approach to compress javascript files is to use GNU zip (GZip) compression ,which is supported by most of the browsers.
Another approach is to minify the Javascript,Minification is the process where we remove unwanted characters like tabs,newlines,spaces,comments reducing file size.
JSMin and YUI Compressor.

8.Always use lower case divs and class names
When compression takes place , It will treat
and
as different tags.Hence its better we have them all in lower case.

9.Delay Script loading ,if possible
Put the javascript at the bottom of the web page.
Often browsers download no more than 2 parallel objects from same domain, If one of those objects is of javascipt code , the download of the other page components will halt until the script is downloaded
Hence give the javascript least priority to get downloaded.
Use either deffered loading or on demand loading of javascript.

10.Use Google gears when available to avoid repeatitive loading of contents.

11.Use the PNG (Portable Network Graphic) format images, PNG provides good quality with optimal file size.

12.Minimize ajax calls, keep them short and to the point

13.Use tools such as JSLint, Firebug, YSlow during development to catch hold of tricky performance issues.

Cheers,
Dhananjay

No comments: