Team LiB
Previous Section Next Section

Speeding Up Your Code

There are a variety of ways in which developers try to decrease the time it takes to download and render their pages. The most obvious is crunching, which is the process of removing excess whitespace in files (since it is collapsed or ignored by the browser anyway) and replacing long identifiers with shorter ones. The assumption is that there will be fewer characters to transfer from the server to the client, so download speed should increase proportionally. There are many tools available on the Web that perform crunching, and the capability may be packaged with commercial development systems as well.

Some tools such as the W3Compiler (www.w3compiler.com) take crunching to the next level. Not only do they perform whitespace removal, but they apply code transformations to JavaScript, CSS, and HTML while preserving the logic and functionality of the page. Special optimization tools like this one may even rearrange your code and combine scripts into external .js files or even inline it as one large <<script>> block, depending on the performance considerations of the page. All these types of techniques attempt to reduce code size to improve download time, but don’t forget about runtime optimizations. If your script performs lots of manipulation of objects or the page’s DOM, consider firing up the Venkman debugger and profiling your code to look for ways to improve runtime execution.


Team LiB
Previous Section Next Section