CSS file validation

I have a CSS file that has grown over time. Many of the coders came and went. The site has changed along the way, and some of the code in CSS is no longer used. Is there a FAST way to check what is used and what is not? I need to remove an OLD code that is no longer in use. Even if there was a "site map" method, it would be even better. Any suggestions please.

+6
html css validation xhtml sitemap
source share
5 answers

If you use Firefox, you can use the Dust Me Selectors plugin, which does exactly what you requested. He finds unused Selectors for you :) Try it!

There is also a CSS Usage plugin that scans your CSS file and tells you which ones are not used. :)

+9
source share
+3
source share

I gave @Kyle Sevenoaks +1 for his answer, since Dust Me Selectors is a very good tool.

However, I would like to add a few points (more than I could fit in a comment, therefore, writing this as an answer):

Even if you have results from Dust Me, you still have to be very smart when viewing results, as they can give false positives and false negatives:

False positives can occur when a selector is specified in your CSS but is not used on the current page. But keep in mind that it can still be used on other pages of the site, so do not just run it on your home page and expect to get the final results; you need to test every page of your site and combine the results.

Also, if you have any Javascript code that adds elements to the page at runtime or changes the class name, they can select CSS selectors that are not used when the page loads first.

False negatives can occur if the selector is used on the page, but is nonetheless redundant because it is always overridden. Sites like the ones you describe are mature candidates for things like this, where a new style was added later for something without deleting the old styles. I don’t know if Dust Me can choose such things, but they can certainly seem difficult, because again you need to be sure that they are really not used in this context or in any other context.

So my message would be that an automated tool is a good idea, and I definitely recommend Dust Me, but don't rely on it.

+2
source share

I found that Dust-Me Selectors works fine for single pages, but I can't get it to scroll the site with 400 + URLS (using an XML file as an index). It usually gets 20 to 30 URLs and then it just hangs. The cumulative report on which selectors are used does not work either - I assume that it simply shows the results for the last page viewed.

I saw similar comments about spidering functionality elsewhere. Maybe it just doesn't work reliably?

0
source share

CSS Formatter and Optimiser + Confirms your CSS in a process that I like: http://www.cleancss.com/

0
source share

All Articles