What is minification:
Minifying your code, means the following:
- Removing white spaces.
- Renaming variables and functions to shorter named ones.
- Removing comments.
There are different stages of minification and obviously each of them delivers different level of compression. One of the most common minifications on the internet is light minification. Only white space and comments are removed. More sophisticated compression includes more modifications to the code.
How to minify your code:
Now days there are many different tools available on the internet that will help you to minify your code. There are installable software as well as web tools. My personal choice is YUI Compressor since I never had any problems with the output and it's quite easy to use. Here is how to minify your code:
- !!! IMPORTANT: Save your original code in another location so you always have a full copy of it.
- Use a minifier to compress your code.
- Replace the code in the JS and CSS files with the output, but ALWAYS have a full version somewhere else.