DropCSS is an unused CSS cleaner; it takes your HTML and CSS as input and returns only the used CSS as output.
DropCSS is an exceptionally fast, thorough, and tiny (~10 KB) unused-CSS cleaner that takes your HTML and CSS as input and returns only the used CSS as output.
The main features of this tool include:
Exceptional Performance: It is engineered for extreme speed, processing test cases in as little as 21 ms, which is significantly faster than alternatives like UnCSS (385 ms) or Purgecss (88 ms).
Precision Cleaning: It removes unused @font-face blocks, @keyframes, and CSS variables, and is capable of deep resolution for composite CSS variables.
Smart Selection Retention: It automatically retains transient pseudo-class and pseudo-element selectors that cannot be deterministically checked from the parsed HTML.
Highly Optimized Parsers: Its custom HTML and CSS parsers are optimized for the 99% use case to avoid the overhead of handling malformed markup, though it requires well-formed input.
Customizable Logic: It features a shouldDrop hook that allows developers to programmatically decide whether to retain or drop specific selectors.
Tailwind CSS Support: Despite being "stupid" regarding unusual selectors, it offers a performant workaround to process complex escaped sequences used by frameworks like Tailwind.
No Runtime Overhead: It does not execute <script> tags or load external resources, ensuring the cleaning process remains fast and predictable.
Whitelist Accumulation: It supports a workflow for purging a single CSS file against multiple HTML sources by accumulating a whitelist of retained selectors.