I needed to implement some CSS compression, and minification, so I made some tests regarding the improvements. The content is delivered by Apache’s GZIP deflate, so the only thing to check was the effect of putting all CSS in one file, and packing it afterwards. For me, the results were surprising.
- Original file, after GZIP (19 CSS files) - 22Kb
- Just included into one big file - 17Kb
- In one file, removed comments and newlines -11kb
- One file, PHP cssTidy-ed - low compression - 10Kb
- One file, PHP cssTidy-ed - high compression - 10Kb
- One file, PHP cssTidy-ed - highest compression - 10Kb
The most interesting part was a difference between 1. and 2. I’m not sure why this happened. The other curious thing is that basically cssTidy compression does not improve much (besides it does changed some margin that I noticed, and did not wanted).
My conclusion: packing all CSS in one file and removing comments and newlines is quite enough.