Settings

Theme

Ask HN: Know of a good tool that finds unused stylesheet selectors and rules?

7 points by apphacker 16 years ago · 5 comments · 1 min read


It seems to be a common problem that as stylesheets mature and the project grows that eventually you may end up in a situation where you are not sure if various styles are still being applied anywhere. Does anyone know of a good way to figure this out with some kind of software tool?

jacquesm 16 years ago

You can't really be sure without running all of your javascript code and checking all of your pages, after all some hidden bit of javascript might change a style based on some event to match one in the css, it might even do it by combining various terms to form the selector, and it might manipulate the ids and classes of elements already on the page.

That's a tricky problem. I'm not aware of a tool, but if you find one I'll be happy to test it, I have a few of those questionable items in my style sheets that are still there 'just in case'.

  • mixmax 16 years ago

    So do I, and it's a pain. some of my CSS files feel bloated and unnecessarily big, but it's an even bigger pain to go through the whole codebase and check everything out by hand.

    It's a problem and if there's a solution out there it would make me very happy.

rarestblog 16 years ago

Google Chrome. Ctrl+Shift+J, Audits tab, Run...

tamersalama 16 years ago

There's a firefox plugin. https://addons.mozilla.org/en-US/firefox/addon/5392/ It has been a while since I last used it but it generally gave good indications.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection