tags:

views:

188

answers:

2

I'm web developer. Before some time I have got the project to maintain. The project is on-line for a few years now and there were few more maintainers before me. Over its lifetime there were many changes in functionality. Many features were added, some of them later were removed as unused. Some from these features required new design elements, so new CSS code were added also. But when these features were removed, added CSS were left. Also every maintainer added his own css styles for small fixes like padding, margins, etc. After a while, CSS files become huge pile of crap :-) I can find many CSS described elements in the same way, but in different CSS file places. Yes, I know that I can minimize and compress CSS files, but I want to clean-up them. So how I can clean-up all this mess?

I need tools/practices/suggestions about these problems:

  • Find the same described elements in different CSS places.
  • Collect unused CSS classes or other descriptions (maybe some tool/browser plug-in which analyses CSS and collects unused styles).
  • Tools to refactor html code by replacing few same described CSS styles to one style.
  • Something else...
+3  A: 

You should give Dust me selector a try. It's a firefox addon that will highlight all unused css. Been very helpful for me =)

Carl Bergquist
I used that too. Only problem is it works OK on 1 file, but when you search on an entire website - not so good...
Faruz
Just checked this tool. I've seen it has sitemap funcion, which allows run checker on all webpages, listed on sitemap. I'm not sure if it collects selectors which is not used on all these pages (havn't tryed yet). If not - it's not problem. With "Dust me selector" user can save collected data to csv files, so you can save results of different pages. Later you just need pick up selectors intersections from data csv files. You'll get list of selectors which were not used in all your pages, you have visited before.
Pawka
+4  A: 

A tool similar to ‘Dust me selector’ is Deadweight, a Ruby command-line tool to find unused CSS rules. But that's only part of your problem… if you ever find tools to do the other stuff you want to do, please let the rest of the world know right here.

avdgaag