Speeding up sites: minifying CSS
I’ve recently started thinking about website speed, thanks in part to three free videos from my alma mater on the topic. As a first step, I’ve tried combining and compressing the CSS files for a recent site I completed, www.luxurycruisebible.com. This has two advantages:
- Smaller overall file size due to compression
- Reduced number of server requests due to combination
Results
The minified and combined css files were 6397 bytes, or just over 30% smaller than the original files. Using Yahoo’s yslow plugin for Firefox, I was able to examine the response times as well, shown in the following table:
| CSS file | size | time |
|---|---|---|
| reset.css | 1001 bytes | 86 ms |
| main.css | 5787 bytes | 174 ms |
| typography.css | 10826 bytes | 255 ms |
| datepicker.css | 2771 bytes | 87 ms |
| previous totals | 20385 bytes | 602ms |
| lcb_comb_min.css | 13988 bytes | 370ms |
Compressors
There are several compressors out there that handle CSS. There is even a comparison tool you can use to see which achieves the best compression.
I used a sort of manual css compressor which seemed to work just fine and is very easy (copy, paste, click) to use. For people comfy with the command line (not me at the moment), there is the Yahoo compressor, and to achieve the compression on the fly, there is a php script from Google, which I plan on trying soon.
Conclusion
As a person who enjoys making websites beautiful and compelling, making them fast doesn’t at first leap to mind as a fun pursuit. However, small steps like CSS compression are easy to do and can significantly improve performance. Next, on to javascript files.
No comments yet…Be the first!
Comments are closed for this article.


Separating the cream from the cruft.