Home     |      Learn AJAX     |      Forum     |      Register     |      Submit Resource     |      Submit Article      |      Contact Us

Home JavaScript
 

JavaScript Compression Techniques

 

Compressing JavaScript coding is almost a regular practice among developers so that they could improve their JavaScript and/or Ajax based application by increasing the load time. Compressors improve the application by increasing the readability without jeopardizing the application. It is a challenging work but it could be done.


Fortunately, the trouble of JavaScript compression is now being handled by JavaScript compression tools. As the name suggests, these tools could compress JavaScript coding for improved loading time.


But developers should not just select a JavaScript compression tool and use it. This form of tools could be divided into three, based on their techniques. You should select a compression tool based on your preferences.


• Whitespace Removers – This type of JavaScript compressor tool aims to remove or discard as much whitespace as it can. A whitespace could easily drag the application since it will require bandwidth just to be ignored later because it is not useful. Although the application may not necessarily become readable, the codes are still there without the whitespace. This is probably the most popular compression technique as it is very simple. This technique is highly recommended for JavaScript heavy websites since it does not implement drastic change on coding.


• Code Rewriters – This very rare technique is considered the opposite of whitespace remover. Instead of simply removing whitespaces in the application, code rewriters change the entire coding so that it will become totally readable by browsers. This is done by parsing JavaScript – a form of technique that divides the coding in the said programming language. After the division of the function, it will be rewritten so that it could work faster. This is a little bit risky but could be done as there are applications that specialize in this type of JavaScript compression.


• JavaScript Compression Tools – While this type of JavaScript compressors sounds redundant, this is the only technique that actually compresses the application. It will completely rewrite the function and add few JavaScript specific additions so that it will be completely renewed for increased interaction. This type of compression tool is very impressive since it will completely implement a “do over” of the functions. Surprisingly, the application will work and will even improve since it will remove all the clutters in the application. Like code rewrites, this form of compression tool is recommended for websites that could be easily controlled.


Caution on Compression Techniques

Although JavaScript compression techniques are compatible in most browsers, there are times that the new function could never be read. If the application is not ready by major browsers it will never work which means the amount spend on compression has been put to waste.


Before you start using any of the compression techniques, it is important to create a back-up for the said functions and webpages. Without any back-up you could start from the scratch rendering all your efforts worthless.


A JavaScript compression tool could do what is asked to do. However, careful selection has to be chosen so that the full features of the compression tool could be used.



Read Next: Free Debugging JavaScript Tools



 

 

Comments



Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links