javascriptcompressionminifyjscompress

Ways to compress/minify javascript files


Duplicate:


So far I have seen these tools to compress javascript files

On Packer page there is a section "Packer versus JSMin" which says that JSMin can be more efficient than Packer. On Yahoo Compressor page it states that Yahoo compressor is more efficient than JSMin, so it looks like Yahoo compressor might be a best candidate.

What is the best option for compressing javascript files?


Solution

  • Yahoo's compressor, for a combination of safety, and decent compression.

    It uses a real JavaScript parser, rather than using a set of regular expressions. It is able to do the same kind of variable renaming that Packer can, but is much safer. It won't break if you forget to put a semicolon at the end of a function definition.

    Packer does have an encoding feature that generates an even smaller file. However, it's only effective if your web server does not support gzip or deflate compression. With gzip / deflate, YUI and Packer generate files that are about the same size.