Skip to content

Consider HTML Minifier Next for HTML minification?#1891

Open
j9t wants to merge 2 commits into
jantimon:mainfrom
j9t:test/hmn
Open

Consider HTML Minifier Next for HTML minification?#1891
j9t wants to merge 2 commits into
jantimon:mainfrom
j9t:test/hmn

Conversation

@j9t
Copy link
Copy Markdown

@j9t j9t commented May 22, 2026

Started off as a test PR: The PR humbly proposes HTML Minifier Next (HMN) as a compatible, maintained, faster, and more secure alternative to HTML Minifier Terser (it’s the official successor to HTML Minifier).

I took care of some small fixes and improvements—quick summary:

  • npm install failures (pre-existing conflicts, unrelated to HMN):
    • typescript@4.9.4 was one patch below what cosmiconfig required—bumped to 4.9.5
    • pug-loader@2.4.0 declares a peer dep on pug@^2, but the project uses pug 3—added legacy-peer-deps=true to .npmrc (pug-loader works fine at runtime with pug 3)
    • webpack-recompilation-simulator@3.2.0 only declares support for webpack 4—same .npmrc fix covers this
  • Tests:
    • Example fixture files (examples/*/dist/webpack-5/) were stale—regenerated
    • One test expected bare defer (development mode, no minifier)—updated to defer="defer" after changing how the plugin sets the attribute
      • Note: I preferred this to stay consistent with the codebase—normally I’d recommend to minimize attributes and enable collapseBooleanAttributes: true (maybe worth considering!)
    • tsc was failing on ...new Set(...) spread because no target was set in tsconfig (defaulting to ES3)—added "target": "es2017" to match the existing lib setting
  • Lint:
    • “Minifier” (as in “HTML Minifier Next”) wasn’t in cspell’s word list—added to .cspell.json
  • Behavioral finding:
    • HMN converts bare deferdefer=defer (valid but unquoted) when the minifier receives it, which differed from the old fixtures. To get the consistent defer="defer" output, I changed attributes.defer = true to attributes.defer = "defer" in generatedScriptTags. This is again to keep things as consistent with possible as with the previous setup.
  • Version and changelog:
    • I didn’t propose anything as it depends entirely on your preferences and decision. If accepted, although fundamentally compatible, I recommend to add a note to double-check output and update settings if needed (also see the following general note).

General note: As mentioned, HMN is fundamentally compatible, but a couple of major changes were introduced, and then it also has some convenience features (like presets) and some new flags that may be worth checking out. I only scanned the list of issues in this repo, but the fixes made in HMN might even help address some issues here.

Happy to help a bit more, but as I maintain HMN I also don’t want to impose—I rather propose this for you to make a call if this is a useful update for HTML Webpack Plugin or not. Cheers!

j9t added 2 commits May 22, 2026 14:07
Signed-off-by: Jens Oliver Meiert <jens@meiert.com>
Signed-off-by: Jens Oliver Meiert <jens@meiert.com>
@j9t j9t changed the title Consider HTML Minifier Next for HTML minification Consider HTML Minifier Next for HTML minification? May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant