Minifying is a technique of removing unnecessary characters from the source code to make it look simple and sleek. The technique is known as minification and code compression.
How did minification work?
The fine way to check out what happens with the code when you minify it, have a look at the Uglify.JS Github Repository. Following are the transformations performed to make the code shorter:
- Removes unnecessary white space
- Use a single character to shorten the variable names
- Converts arrays into objects (where possible)
- Joins consecutive var declaration
- Optimize if statement
- Calculate simple constant expression etc.
Java minification tools
These tools can be categorized into 3 categories:
- Online tools– it is a matter of pasting the code and copying results immediately. The nice thing about the online tools is its speed with which you can work.
- Online YUI compressor- it is a powerful tool that also uses YUI compressor with lots of CSS minification capabilities to make the code neat.
- jscompress.com is no frill minified.
- jsmini.com is a simple but usable option.
- GUI tools– it contains a lot of functionality, JS minification is just a small part of what they do.
- Koala is a free tool for Less compilation, SAAS compilation, JS minification, etc.
- Code-kit is a Mac-only app is a paid app that offers code compilation, minification, package management, a preview server and much more.
- Smaller is an OS X tool that minifies files for you.
Here I have mentioned two types of GUI.
- Command-line tools– these are also more comprehensive and offering minification as a module.
- Minify it is a minifying tool for those developers who want to minify JS from the command line.
- Gulp- as another minifying tool gulp has JS minification using Uglify.js, which will quickly remove unnecessary content.
Gulp and Grunt are easy through their documentation. The upside of command tools is an awesome amount of flexibility.