Uncss – Find unused CSS(davidwalsh.name) |
Uncss – Find unused CSS(davidwalsh.name) |
I wrote and maintain this project for the last 4 years.
There are issues with David Walsh's approach that are explained in the Helium README. Automatic stylesheet generation is a terrible idea, for one.
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.
The challenge, of course, is that's it's hard to say for sure that something is unused. Maybe it's only called on one page, or only after some interaction with javascript on the page.
That's why I will use a prefix js-[something] for elements that will interact with javascript and then user other classes for style so nothing gets removed by accident by others.
I'm thinking about building URL workflows (stored in arrays) and passing authentication tokens via URL.