Cult-Foo

JavaScript Compression

Tags:

If you developing rich web applications, you start to think how to compress JavaScript to keep bandwidth and page load times as small as possible. I found 5 different tools to compress javascript files, which can be run using cron, or run on some event to automate work on production-server.

1. JSMin. Commonly used compressor, based on simple rules, ported on many languages, including JavaScript

2. JavaScript::Minifier. Separate perl module, compression ratio equal to JSMin

3.Dojo ShrinkSafe aka Rhino. JavaScript compressor that parses the JavaScript using the rhino library, included in Dojo. Run as jar-module.

4. Dean Edwards Packer. Well-known tools from far-famed Dean Edwards. Ported on some languages, including PHP4/5.

5. YUI. JavaScript minifier designed to be 100% safe and yield a high compression ratio. Run as jar-module.

From my own experience i can tell
– no sense to compress files less 1 kb
– packer shows best results ( just my own opinion )
– always check you functionality of your compressed files. You can try to verify your code with JSLint
– remember that you can gzip compressed files to get smaller file

Good article about gzipping js

Managed WordPress Hosting

Did you like it? Help us spread the word!

Do you have something to say?