Say you had a dynamically generated site that has been worked on by too many people, past and present, and you now have a collection of shared stylesheets that contain over 20,000 lines of CSS. It isn't organized at all, there are some class and id-based selectors but also way too many tag-based selectors. And then say you have 100 templates that use these styles, via some controller.
Is there a tool, something that works like Firebug perhaps, that you can point at a url and it would determine all of the applicable CSS selectors for that page and dump them to a file? Basically some way to rip apart the shared stylesheets on a page by page basis.
I've used Dust-Me Selectors before, which is a Firefox plugin. It's very easy to use and versatile as it maintains a combined list across a number of pages of which CSS values are used.
The downside is that I wasn't able to automate it to spider an entire site, so I ended up using it just on key pages/tempates of my site. It is very useful nonetheless.
Hands down the best one that actually does exactly what you want by only getting the used css on the page and allows you to simple copy it to your clipboard and paste it is this Chrome extension CSS Used
Check for PurifyCSS, and this for those who can handle CLI or Gulp/Grunt/Webpack
检查PurifyCSS,以及那些可以处理CLI或Gulp / Grunt / Webpack的人
You can remove the unused style from single page or multiple page or from the entire project, even thought the classes are being injected by Javascript.