0

I'm looking for automated tools to help me refactor a bunch of CSS files, for example:

  1. Remove unnecessary selectors (e.g. not used inside the page)
  2. detect repeatable rules inside several selectors and suggest a merge

Are there any such tools?

Thanks!

1
  • Writing one wouldn't be that hard if you have scripting experience (Python, PHP, Perl, etc.). Depending on the complexity, of course.
    – Brigand
    Jan 4, 2012 at 22:03

3 Answers 3

1

Yes Google Page Speed does this CSS investigation. Link:

http://code.google.com/speed/page-speed/docs/overview.html

1

not totally automated, but this one works well.

I like the fact that I can see what I'm changing. While I've done UI for 15 years, there's always little things that I notice myself repeating via using this tool. In the long run, doing things a bit manually is going to make me a better developer.

Doing one that looks for unnecessary selectors is a dangerous game. You could do it, but if you ever find yourself doing dynamic and/or ajax injected divs, you'll immediately blow up your page or app using an automated tool. If you do it, make sure it's not something that works on the fly, without some sort of very good testing environment to verify the resulting output. My current corporate clients would never allow me to use any sort of point-of-request tool based on their requirements of 100% tested and verified CSS.

1
  • I agree. I'm looking more for a suggestions tool than a modifying tool. Jan 4, 2012 at 22:10
0

This tool can do automatic css refactoring, though its value in project still need to evaluate carefully.

Not the answer you're looking for? Browse other questions tagged or ask your own question.