Comparing compression tools

I covered three of the most popular compression tools. Each tool has its pros and cons. As always, the right tool for you is the one that best fits your needs. The following table summarizes the results in bytes you can get compressing require.js 2.1.8 with the tools I just discussed:

File

Original size

Compressor

Size

require.js

82944

UglifyJS2

24576

Google Closure

13312

R.js

15360

As you can see, in this example, UglifyJS2 yields the best result but that is not always the case. If you run the same tests on the popular raphael.js library, you get instead the best result with Google Closure Compiler. The results vary depending on the source code writing style; for this reason there is no single best tool to use. I prefer r.js because it can run the compressor engine as well as handle the plugins and module dependencies very well.

Note

Other compression tools you may consider include KJScompress, Bananascript, JSMin, ShrinkSafe, and YUI Compressor.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.48.181