HTML Minifier Next: Presets, New Config Options, Minification Sharing, and Type Definitions
Published on DecĀ 11, 2025, filed under development, html. (Share this post, e.g. on Mastodon or onĀ Bluesky.)
If youāre using tooling to minify and optimize your production HTML, you might like the following updates to HTML Minifier Next (HMN), the enhanced successor of HTML Minifier. Iāve been investing a bit of time into both fixing issues reported in the predecessor and modernizing the minifier:
Improved Performance
HMN comes with several performance optimizations, including a small LRU cache for CSS and JavaScript minification and faster hot paths. Although ultimately depending on the chosen config and the document in question, these optimizations improve HMN speed overall.
Clearer Docs
Whether general information or details for flags, the documentation hasnāt always been clear. The README is more detailedāand hopefully more usefulāthan ever, and parameters, including in the CLI, should be better documented.
Presets
To make it easier to use HMN out of the box, HMN introduced presets: āconservativeā (basic starter HTML minification) and ācomprehensiveā (more aggressive but generally safe HTML, CSS, and JavaScript minification). These can be invoked in config files (e.g., "preset": "conservative") and via CLI (as in --preset=comprehensive), and still allow fine-grained overrides.
Support for Partial Markup and Empty-Element Exceptions
Addressing two feature requests, HMN added support for partial markup with the partialMarkup parameter (where stray end tags are not removed and start tags not closed), and the option to specify empty elements not to be removed when removeEmptyElements is being set, via the removeEmptyElementsExcept parameter.
Minification Sharing
The minifier web version now allows to share configurations (long HTML docs) including their results (short docs):
See it in action for the classic most minimal HTML ātemplate.ā
Type Definitions
Iām not a TypeScript person (is this a thing?), but thanks to Jonas Geiler, to improve the developer experience, HMN also ships with type definitions. YesĀ āļø
_ These are six of a few more updates. HMN is under active development and it seems fair to say that itās currently the most effective HTML minifier on the market, and the most efficient member of the html-minifier-x franchise. Thereās still a lot to do though, and given other maintained options, itās going to be exciting to make it even better. Please report errors and share suggestionsāIāll keep you posted on the next changes.
About Me
Iām Jens (long: Jens Oliver Meiert), and Iām a web developer, manager, and author. Iāve been working as a technical lead and engineering manager for companies youāve never heard of and companies you use every day, Iām an occasional contributor to web standards (like HTML, CSS, WCAG), and I write and review books for OāReilly and Frontend Dogma.
I love trying things, not only in web development and engineering management, but also in other areas like philosophy. Here on meiert.com I share some of my experiences and views. (I value you being critical, interpreting charitably, and giving feedback.)
