Hacker News new | ask | show | jobs
by clutchski 4406 days ago
If this worked across a whole site rather than a single page, that would be great.
1 comments

Exactly. Sitepoint made a browser extension to do this years ago but it's not really actively maintained anymore: http://www.brothercake.com/dustmeselectors/
There is an add-on for Firebug too (https://addons.mozilla.org/en-us/firefox/addon/css-usage/) -- I use it a big corp. Basically if there is some wild huge monolithic css file I'll cut a new one for a site & use this to pick a decent-looking base subset from the existing dung heap. Then I'll use it again later to analyze widgets etc. if someone complains "how come ______ doesn't look like it does on the old site?".

I'd love for this all to be automated but it seems there are some fundamental flaws in that. Sometimes unused css still fits into a logical unit and should be included. Sometimes in-use css is just a piece of garbage innocuously clinging to some jagged edge of the DOM.

I try to comment blocks of CSS with both starting and ending comments, "______ START" to "_______ END" to avoid this. That way I can extract those pieces later without really worrying that I'm mangling a code module, manually, without much fear.