Spread the word

Wednesday, January 28, 2009

How to find unused CSS classes and selectors within a website

Many times we think of using some class or id within a CSS but later on decide not to use them finally. But several times we forget to delete those classes from the CSS file. This may not be a problem for sites where the use of CSS is very less. But this may be accountable for much junk lines within your CSS which are unnecessary and unwanted.



Many times it happens that we use more than one CSS files for a site or application and copy many unused classes or ids. This way the amount of code loaded every time becomes a much considerable value. These unwanted CSS selectors should be deleted from the CSS files. To delete those unused CSS selectors you first need to identify them.

Sitepoint has released a very good tool for this purpose. Dust-Me Selectors is a very useful Firefox Extension which helps you to easily identify those unused CSS selectors. It also has some added advantages. It understands the different ways to include and import CSS files within webpages and also can check inline CSS styles. Importing stylesheets within the IE Conditional Comments is well parsed by this tool. It also understands well known CSS hacks. You can even check a whole site directly with this tool. Just install this Dust-Me Selectors Extension to your Firefox browser and remove the junk codes within your CSS, if any. Make more clean and useful CSS from now.

6 comments:

Ken said...

Dust-Me Selectors is a very useful Firefox Extension indeed but is working only on one single website page at a time. If you have 1,000 pages on your website, Dust-Me Selectors is just useless.

software testing services said...

Cleaning while programming is really important. I like Dust-Me Selectors but like Ken above, I have to agree that when I work it on bigger sites it's not helpful anymore. It's great when you have small sites with only a few pages, though. :)

климатици said...

great article thanks for share

freelancer said...

I learned lot of new things which explores my knowledge in various development,thanks.

Jimmy said...

Just what I needed, thanks

Power Click said...

The post is written in very a good manner and it entails many useful information for me. I am happy to find your distinguished way of writing the post. Now you make it easy for me to understand and implement the concept. Thank you for the post

Post a Comment