Jens Oliver Meiert

HTML Minifier Next: Presets, New Config Options, Minification Sharing, and Type Definitions

Published on DecĀ 11, 2025, filed under , . (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):

Minify or share.

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

Jens Oliver Meiert, on November 9, 2024.

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.)