Speed up your website…

If you make dynamic websites and heavily use javascript, maybe these hints can help you out.

1. merge all your javascripts in one “big” javascript. Reason – to reduce number of network calls.

2. compress you javascript file. I don’t mean to gzip them, it is the next step. By compressing I mean to remove all unnecessary whitespace and comments. That can significantly reduce file size.

Here are some of the online javascript compressors:

* http://www.creativyst.com/Prod/3/
* http://www.dithered.com/javascript/compression/
* http://rumkin.com/tools/compression/compress_huff.php
* http://javascript.about.com/library/blcrunch.htm
* http://javascriptcompressor.com/
* http://www.brainjar.com/js/crunch/demo.html

And one excellent commercial: http://www.codehouse.com/products/soc/
(there is 30-day trial period, so you can test it).

My experience showed me that you should not trust these tools completely. Take your javascript, run it through compressor and put it back to your application to see if it use. Most of those online tools made few errors here and there. Commercial tool SOC did the job without any error.

3. gzip response. This is widely used and almost a must in all today’s applications. Usually you would configure your webserver for this (Apache mod_gzip or for Tomcat compresion=”onî in server.xml), but you can do it also over servlet filter.
Here is one that works – download gzip.rar.

All these things reduced my .js size by more then 60% and that is a huge win.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s