Compressing CSS

When building CSS based websites the CSS files can quickly get quite large. I’ve been working in projects where the file can go up to 30-40kB for the styles. And then I have used shorthand version of the rules.

So is there another way to make file smaller?

Yes, I found an really easy way, compress the file with an small freeware program called HTML compress.

Screendump of HTML Compress

By running the CSS file through this program you reduce the size with roughly 20% - 40%. That is quite a lot. If having a file of 45kB it turns out 30kB.

As an example I took Red Hats website that uses tableless design with a CSS file that is 4.8kB. After running this file through the program the file turned out 3.1kB. An reduction of 35%.

After the file has been compressed the content is quite unreadable for an human eye. So this should of course be done when the CSS file is finished.

Compressed CSS code

I have not extensively tested this is on large CSS files with a lot of hacks. I know this program removes all comments so please let me or the author of program know the problem if you find any.

Related Posts:

  • None

External links

Leave a Reply


Jens Wedin Mail me Portfolio