tags:

views:

59

answers:

4
+5  Q: 

CSS out of control

Are there any utilities that will crawl a site and determine which css rules are in use and which are not? We have a large site and a huge CSS file (--don't blame me I just got here). And, I think much of it is not being used however I'm afraid to strip stuff out just in case.

The file is confusing and difficult to manage and I think if we can trim it down by getting rid of the unused rules we will have a good starting point to go through and try to make it better.

+4  A: 

Try the Dust-Me Selectors Firefox extension by SitePoint. It finds CSS selectors whose rules are never applied to your pages so you can remove them from your stylesheets.

BoltClock
Very cool. Just tried it. Works exactly as advertised.
Kirk Woll
Dust-Me is cool as well. Maybe I'm not seeing it but is there a way to get a trimmed CSS file from the results? I like the crawl a sitemap option.
Paul
@Paul: now that you mention it, I don't think so, but it's immensely useful in pinpointing them in the stylesheets for you so you can remove them more quickly.
BoltClock
+3  A: 

https://addons.mozilla.org/en-US/firefox/addon/10704/?src=collection&collection_id=23d14a2d-b396-c08f-e9ba-b4d34691d5a9

It's an addon in Firebug.

Paul
This one is very cool...I like the option to export a trimmed css file.
Paul
+3  A: 

I had the same problem a while ago (5k lines in a CSS) and found this Firefox Plugin which worked very well for me.

halfdan
+1 for the addons.mozilla.org link. I provided the link to its home page on sitepoint.com, but I think links to AMO are better since it's the official add-on repository.
BoltClock
+1  A: 

The Google Page Speed plugin for Firefox's Firebug addon is also a great tool that will highlight the unused CSS selectors as well as inform you which ones are poor performers.

As always though, you need to be aware that the CSS selector may not be used on "this" page but may very likely be used on another page so be careful when pruning them to ensure they are truly unnecessary.

scunliffe
+1 for the caveat of active CSS selectors being dependent on pages (so trimming to match the HomePage may break another page down the track).
Lucanos