Optimize Your CSS

The combination of XHTML and CSS can reduce size of a webpage, mainly by freeing up the layout from HTML tables. This does not mean that any XHTML and CSS code can do it. It has to be done the right way to be effective.

Here is where we use CSS Optimization, to make sure that we are using the leanest CSS possbile, which will reduce the bandwidth consumption and in turn increase the website performance. I came across CSS Tweak by Andy Peatling.

For people who have no idea what I’m talking about, CSS Tweak is a web based CSS optimization tool. It will take any CSS file and optimize the syntax, grouping your style declarations into shorthand where possible. It can also remove comments, and strip whitespace for maximum compression.

The one thing that makes it different from other tools however, is you can also stop it from altering your syntactical layout at all. Instead it will go through and stick with the layout you have defined, and clean up any areas that are incorrectly formatted.

CSS Tweak is a smart tool because it gives you control over the optimization that you want to do, including maintaining layout of the CSS file. The highest level of optimization removes white space, carriage returns, comments, everything. Help is provided to explain the options provided. You can control the level of optimization you want to do through the options given. One of my CSS files was reduced by 37% in size when full optimization was used.

CSS Tweak thumbnail

There are other tools out there which offer optimization like CSS Optimiser. However CSS Tweak stands out because of the finer control it offers to the users. As noted in the article, the CSS is only optimized, not validated. For CSS validation you can use W3C tool online or through Web Developer extension for Mozilla firefox.

Copyright Abhijit Nadgouda.

Say your thought!

If you want to use HTML you can use these tags: <a>, <em>, <strong>, <abbr>, <code>, <blockquote>. Closing the tags will be appreciated as this site uses valid XHTML.



Abhijit Nadgouda
iface Consulting
+91 9819820312
My bookmarks


This is the weblog of Abhijit Nadgouda where he writes down his thoughts on software development and related topics. You are invited to subscribe to the feed to stay updated or check out more subscription options. Or you can choose to browse by one of the topics.