Comparison of JavaScript compression methods

While creating the build system for our Java web application, I set out to do some benchmarking on some of the different JavaScript compression methods. When our project builds, I configured our Ant build script to create three different version of our JavaScript files; full source, minified (comments and whitespace removed), and packed (compressed).

I also configured Tomcat to use gzip compression and then ran six different test, the three version of our JavaScript files without gzip compression and the three versions with gzip compression.

I measured the load time and size using FireBug from within Firefox and recorded the following results:

Full Source Minified Packed
Without GZIP 167 KB | 329ms 95 KB | 281ms 70 KB | 313ms
With GZIP 67 KB | 297ms 48 KB | 219ms 47 KB | 312ms

Although my "tests" are very informal, I think that it is clear that the minified version with GZIP server compression offers the best results. It is only slightly larger than the packed version in size, but it loads almost 30% faster (due to the overhead of decompressing the packed version).

Topics: ,


  1. February 7, 2008 @ 4:20 am #

    Hi, how can i "GZIP" .js files using windows?
    Is there any GUI mode?

    Or like the Packer URL version? (


  2. February 7, 2008 @ 8:44 am #

    @Santiago - gzip, as mentioned here, refers to the HTTP response compression by a web server and decompression by the web browser. So it's not something you can physically do to a file. (UPDATE: Yes, you can physically compress a file using gzip, but this post is referring to server compression - thanks Peter)

    Here is a great article that explains it all:

  3. February 14, 2008 @ 5:31 am #

    OK. thanks!

  4. February 14, 2008 @ 4:36 pm #

    Eric: gzip is the standard compression used on unix machines, it is indeed something a user can do to a file. WinZip and other Windows archiving platforms support compression and decompression.

    Also see another take on the question.

  5. February 14, 2008 @ 5:13 pm #

    @Peter - I prefaced my response with "gzip, as mentioned here, refers to...". I'll change last sentence to be more clear, but again, I was speaking in terms of server compression not physical file compression.

  6. August 29, 2008 @ 8:55 am #

    How can I use javascript compression with IIS?

  7. August 29, 2008 @ 9:27 am #

    @dnd - IIS 5.0, IIS 6.0, or IIS 7. HTTP Compression is not available in IIS 5.1 [reference]. I also don't think IIS 4 or lower support HTTP compression'd need to install third-party software.

    IIS version -> OS version list:

Leave a Comment

Sorry, comments are closed. You can contact me directly, if you like.

Eric Martin