Remove Unused CSS Rules

Remove Unused CSS Rules

A monolithic style sheet is difficult to reason about, which is challenging as CSS files tend to attract bloat. Removing unused styles can help make the situation more manageable.

[…]

Part of the returned results will likely include Remove unused CSS rules. If this is missing, it means you don’t have any unused CSS rules. Congratulations!

[…]

I initially preferred UnCSS and the command line convenience. However, since drafting this article I’ve tried this out on a few more sites and had less promising results. Most notably, I have several sites built a few years ago that made use of a framework that implements persistent comments using the /*!*...*/ notation. This doesn’t play nicely with PostCSS and thus UnCSS. I haven’t dug into the issue further, potentially a newer PostCSS script is more forgiving of this type of comment, but for now it’s another barrier stopping UnCSS becoming a more common part of my workflow.