Compressing your CSS Stylesheet

Compressing your CSS file is a great way to save bandwidth especially on big websites. The are loads of firms that will compress the CSS files for you but the problem is that you need to recompress it after each modification.

To solve this and do the compression yourself you need to write a few lines of PHP code.

Read the tutorial here 

Posted in : CSS, Tutorials
Post statistics : 200 views
Bookmark and Share

Quick Share

If you enjoyed this post, please consider to leave a comment or subscribe to the RSS feed and get future articles delivered to your feed reader or directly in your email box.

Comments

Ingeniously, I can use well.

I have come across CSS compression before, but have found that the removal of white space during compression only amount to a few kb maximum saving on the file size much better to shave of the files size of Images or Flash or other objects.

I have found the best approach is to use the @import and separate the style sheets out for individual templates. This works great with the CSS being cache in the browser at initial download. So you only download the CSS you require for that page! Back to the CSS, if you code each declaration line by line and using inheritance also makes the CSS more readable e.g.

div.ClassName p { some: XXX; styles: XXX; here: XXX;
div.ClassName p.OtherClassName { }

When I say more readable, it makes it easier to traverse the DOM and find out the specificity of the styles in conjunction the semantics of the HTML you are styling.

Leave a comment

(required)

(required)