Unused CSS is a hard problem because of how hard it is to know for sure know if a ruleset is unused. Robert Kieffer's solution is to load up document.styleSheets and find all the rules (the ones that are classes) Then, use a MutationObserver to watch the DOM for all HTML. If the HTML has a class not found in a stylesheet, report it.
2 Comments
Sort: