HTML Minifier Next: Unused-CSS Removal, Improved Web Demo, and Greater Versatility, Security, and Performance
Published on Sep 3, 2026, filed under tools, development, html, performance, optimization. (Share this post, e.g., on Mastodon.)
HTML Minifier Next (HMN)—as per my own good-faith benchmarks the most effective web page minifier—received a number of updates over the last few weeks. As in the past, some quick highlights:
Remove Unused CSS via removeUnusedCSS
Inline CSS minification has already been quite effective via Lightning CSS; with 7.6.0, HMN reduces CSS payload by also removing any unused CSS. As per the documentation:
removeUnusedCSSremoves rules fromstyleelements whose class or ID selectors the document doesn’t reference. It needs to be used withminifyCSS, because the removal runs through Lightning CSS—passingminifyCSSa function of your own replaces that step, so the removal does not apply, either. Both cases are reported through theloghook. It does not touchstyleormediaattributes.const result = await minify(html, { minifyCSS: true, removeUnusedCSS: true });
Try and Analyze Minification Setups
The online minifier (aka web demo) now makes minification and minification debugging a bit easier by showing (some) invisible characters:
The option can be particularly helpful to explain and debug whitespace-collapsing behavior.
Thanks fermiongithub for the suggestion!
Enjoy Higher Versatility (i.e., Run Into Fewer Esoteric Bugs)
HMN contains many fixes for by now serious problems in the HTML Minifier and HTML Minifier Terser predecessors—for example, both would silently remove some modern CSS.
However, like any moderately complex piece of software, HMN also contains bugs, which may lie dormant for some time. HMN 8.0.0 and later include a variety of bug fixes, largely for issues that are “esoteric” (rare), improving HMN even further.
Enjoy Improved Security With strictCustomFragments
With HMN 8.0.0, customFragmentQuantifierLimit was deprecated, strictCustomFragments introduced, and a number of adjustments were made to avoid catastrophic backtracking while simultaneously improving developer experience.
The README section on ReDoS protection has more details on regexes in HMN.
Enjoy Better Performance
I regularly look for opportunities to make HMN faster. This is getting harder and harder as HMN gets more and more optimized, but there were a few options, making HMN ~10% faster again (ballpark number as it depends on the code being minified). I’ll keep this part brief: Minifier Benchmarks has some data on HMN performance and effectiveness.
This is it for some of the last changes. As usual, if you run into an issue or have a suggestion, please file an issue. If you or your organization get value out of this work on HTML Minifier Next, please support the project. Thank you!
About Me
I’m Jens (long: Jens Oliver Meiert), and I’m an engineering lead, guerrilla philosopher, and indie publisher. I’ve worked as a technical lead and engineering manager at various companies (e.g., Google); I’m an active web and tool developer (code optimization, digital defense), a contributor to web standards (like HTML, CSS, WCAG), and a book author (O’Reilly, Frontend Dogma).
I love trying things—in web development and engineering management, but also in politics and philosophy, where I hold to one idea in particular: that we can only be well if we take good care of everyone. Here on meiert.com I talk about some of my perspectives and experiences. (Interpret charitably but be critical—and share feedback and advice that makes my work better.)
