A simple way to increase page speed is to minify your external files and website coding. Not to be confused with minimizing, minifying code is the process of making files appear smaller by removing white space and unnecessary line breaks. The code itself does not change, but rather its perceived appearance. Minimizing, on the other hand, is a concerted effort to reduce the amount of tags and data by removing, combining or condensing code. This is far simpler.
Example 1: Regular CSS Expression
padding-left:10px;
padding-right:10px;
color:#000000;
font-size:11px;
padding-top:3px;
}
Example 2: Minified CSS Expression (86% smaller)
The only difference is the amount of white space or empty characters. Each empty character accounts for just a few bytes but when you’ve got big CSS and Javascript files, it adds up- as you can clearly see by the 86% size reduction. These compression results are not atypical. Some file types you can minify include CSS, Javascript, HTML and PHP.
Minification Methods
1. Manual: Using the delete, backspace or some form of highlight and erase. So-so method.
2. Automatic: Use a compression tool that allows you to copy and paste your code, compress it (IE removing all empty spaces}, then copy and paste it back. This method is ideal, although not always feasible.
Minification Steps
We’re choosing method #2 with the fail-safe and option.
Step 1. Create backups of all files you plan to minify.
Step 2. Open a file ending in .js, .css, .html or .php.
Step 3. Highlight the code and copy it into this compressor tool.
Step 4. Hit ‘decode’ and copy the minified version back into your file- replacing the original code.
Fail-Safe: Save and test in multiple browsers.
Option: Try manual minification if the tool is over-compressing your browser refuses to load it.
Keep In Mind
- The tool is, technically, called a javascript compressor. Don’t worry, it works with other languages.
- Sometimes it can over-compress and render the code unreadable. It’s usually a small issue, but without programming language knowledge, fixing it is not really an option. This is when the manual method comes into play.
- Some browsers will ignore any over-compression while others will refuse to load it. Testing is crucial.