html-minifier-next 5.0.3 → 5.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -397,47 +397,7 @@ Available options:
397
397
 
398
398
  ## Minification comparison
399
399
 
400
- How does HTML Minifier Next compare to other minifiers? (All minification with the most aggressive settings—though without [hyper-optimization](https://meiert.com/blog/the-ways-of-writing-html/#toc-hyper-optimized)—and against a wide range of pages.)
401
-
402
- <!-- Auto-generated benchmarks, don’t edit -->
403
- | Site | Original Size (KB) | [HTML Minifier Next](https://github.com/j9t/html-minifier-next) ([config](https://github.com/j9t/html-minifier-next/blob/main/benchmarks/html-minifier.json))<br>[![npm last update](https://img.shields.io/npm/last-update/html-minifier-next)](https://socket.dev/npm/package/html-minifier-next) | [htmlnano](https://github.com/posthtml/htmlnano)<br>[![npm last update](https://img.shields.io/npm/last-update/htmlnano)](https://socket.dev/npm/package/htmlnano) | [@swc/html](https://github.com/swc-project/swc)<br>[![npm last update](https://img.shields.io/npm/last-update/@swc/html)](https://socket.dev/npm/package/@swc/html) | [minify-html](https://github.com/wilsonzlin/minify-html)<br>[![npm last update](https://img.shields.io/npm/last-update/@minify-html/node)](https://socket.dev/npm/package/@minify-html/node) | [minimize](https://github.com/Swaagie/minimize)<br>[![npm last update](https://img.shields.io/npm/last-update/minimize)](https://socket.dev/npm/package/minimize) | [html­com­pressor.­com](https://htmlcompressor.com/) |
404
- | --- | --- | --- | --- | --- | --- | --- | --- |
405
- | [A List Apart](https://alistapart.com/) | 63 | **53** | 55 | 56 | 55 | 58 | 56 |
406
- | [Apple](https://www.apple.com/) | 236 | **198** | 209 | 212 | 213 | 215 | 215 |
407
- | [BBC](https://www.bbc.co.uk/) | 651 | **605** | 611 | 612 | 613 | 646 | n/a |
408
- | [CERN](https://home.cern/) | 150 | **80** | 90 | 90 | 90 | 92 | 95 |
409
- | [CSS-Tricks](https://css-tricks.com/) | 155 | 127 | **121** | 136 | 137 | 141 | 138 |
410
- | [ECMAScript](https://tc39.es/ecma262/) | 7261 | **6447** | 6583 | 6465 | 6589 | 6637 | n/a |
411
- | [EDRi](https://edri.org/) | 80 | **68** | 69 | 69 | 71 | 74 | 72 |
412
- | [EFF](https://www.eff.org/) | 54 | **45** | 49 | 47 | 48 | 49 | 49 |
413
- | [European Alternatives](https://european-alternatives.eu/) | 48 | **30** | 32 | 32 | 32 | 32 | 32 |
414
- | [FAZ](https://www.faz.net/aktuell/) | 1519 | 1389 | **1364** | 1446 | 1457 | 1467 | n/a |
415
- | [French Tech](https://lafrenchtech.gouv.fr/) | 153 | **122** | 126 | 126 | 126 | 132 | 127 |
416
- | [Frontend Dogma](https://frontenddogma.com/) | 227 | **219** | 240 | 225 | 227 | 246 | 226 |
417
- | [Google](https://www.google.com/) | 18 | **16** | **16** | **16** | 17 | 18 | 18 |
418
- | [Ground News](https://ground.news/) | 1465 | **1328** | 1350 | 1372 | 1377 | 1453 | n/a |
419
- | [HTML Living Standard](https://html.spec.whatwg.org/multipage/) | 149 | 148 | 153 | **147** | 149 | 155 | 149 |
420
- | [Igalia](https://www.igalia.com/) | 49 | **34** | 36 | 36 | 36 | 37 | 37 |
421
- | [Leanpub](https://leanpub.com/) | 241 | **224** | 226 | 226 | 227 | 236 | 238 |
422
- | [Mastodon](https://mastodon.social/explore) | 38 | 35 | **32** | 35 | 36 | 37 | 37 |
423
- | [MDN](https://developer.mozilla.org/en-US/) | 109 | **63** | 64 | 65 | 65 | 68 | 68 |
424
- | [Middle East Eye](https://www.middleeasteye.net/) | 220 | **194** | 200 | 198 | 198 | 199 | 200 |
425
- | [Mistral AI](https://mistral.ai/) | 343 | **307** | **307** | 310 | 311 | 340 | n/a |
426
- | [Mozilla](https://www.mozilla.org/) | 47 | **32** | 35 | 35 | 35 | 36 | 36 |
427
- | [Nielsen Norman Group](https://www.nngroup.com/) | 97 | 73 | **59** | 78 | 80 | 81 | 81 |
428
- | [SitePoint](https://www.sitepoint.com/) | 494 | 456 | **431** | 468 | 473 | 491 | n/a |
429
- | [Startup-Verband](https://startupverband.de/) | 43 | **30** | 31 | **30** | 31 | 31 | 31 |
430
- | [TetraLogical](https://tetralogical.com/) | 59 | 52 | **49** | 51 | 53 | 53 | 53 |
431
- | [TPGi](https://www.tpgi.com/) | 173 | **157** | 159 | 163 | 164 | 170 | 170 |
432
- | [United Nations](https://www.un.org/en/) | 151 | **113** | 121 | 125 | 124 | 130 | 123 |
433
- | [Vivaldi](https://vivaldi.com/) | 93 | **76** | n/a | 79 | 81 | 84 | 82 |
434
- | [W3C](https://www.w3.org/) | 50 | **36** | 39 | 38 | 38 | 41 | 39 |
435
- | **Average processing time** | | 83 ms (30/30) | 165 ms (29/30) | 47 ms (30/30) | **13 ms (30/30)** | 283 ms (30/30) | 1254 ms (24/30) |
436
-
437
- (Last updated: Feb 4, 2026)
438
- <!-- End auto-generated -->
439
-
440
- Notes: Minimize does not minify CSS and JS. [HTML Minifier Terser](https://github.com/terser/html-minifier-terser) is currently not included due to issues around whitespace collapsing and removal of code using modern CSS features, issues which appeared to distort the data.
400
+ Please see [**the Minifier Benchmarks project**](https://github.com/j9t/minifier-benchmarks) for details on how HMN compares to other minifiers.
441
401
 
442
402
  ## Examples
443
403
 
@@ -641,27 +601,15 @@ For CLI usage, using a config file is strongly recommended to avoid complex shel
641
601
  npm run serve
642
602
  ```
643
603
 
644
- ### Benchmarks
645
-
646
- Benchmarks for minified HTML:
647
-
648
- ```shell
649
- cd benchmarks;
650
- npm i;
651
- npm run benchmarks
652
- ```
653
-
654
- (In case of dependency conflicts, run `npm i` with the `--legacy-peer-deps` flag.)
655
-
656
604
  ### Regression tests
657
605
 
658
606
  ```shell
659
- cd benchmarks;
607
+ cd backtest;
660
608
  npm i;
661
609
  npm run backtest
662
610
  ```
663
611
 
664
- The backtest tool tracks minification performance across Git history. Results are saved in `benchmarks/backtest/` as CSV and JSON files.
612
+ The backtest tool tracks minification performance across Git history. Results are saved in the backtest folder as CSV and JSON files.
665
613
 
666
614
  Parameters:
667
615
 
@@ -4377,9 +4377,10 @@ async function minifyHTML(value, options, partialMarkup) {
4377
4377
  optionalStartTag = '';
4378
4378
  // `</html>` or `</body>` may be omitted if not followed by comment
4379
4379
  // `</head>` may be omitted if not followed by space or comment
4380
- // `</p>` may be omitted if no more content in non-`</a>` parent
4380
+ // `</p>` may be omitted if no more content in parent, unless parent is in `pInlineElements` or is a custom element
4381
+ // https://html.spec.whatwg.org/multipage/syntax.html#optional-tags
4381
4382
  // except for `</dt>` or `</thead>`, end tags may be omitted if no more content in parent element
4382
- if (tag && optionalEndTag && optionalEndTagEmitted && !trailingElements.has(optionalEndTag) && (optionalEndTag !== 'p' || !pInlineElements.has(tag))) {
4383
+ if (tag && optionalEndTag && optionalEndTagEmitted && !trailingElements.has(optionalEndTag) && (optionalEndTag !== 'p' || (!pInlineElements.has(tag) && !tag.includes('-')))) {
4383
4384
  removeEndTag();
4384
4385
  }
4385
4386
  optionalEndTag = optionalEndTags.has(tag) ? tag : '';
@@ -6990,9 +6990,10 @@ async function minifyHTML(value, options, partialMarkup) {
6990
6990
  optionalStartTag = '';
6991
6991
  // `</html>` or `</body>` may be omitted if not followed by comment
6992
6992
  // `</head>` may be omitted if not followed by space or comment
6993
- // `</p>` may be omitted if no more content in non-`</a>` parent
6993
+ // `</p>` may be omitted if no more content in parent, unless parent is in `pInlineElements` or is a custom element
6994
+ // https://html.spec.whatwg.org/multipage/syntax.html#optional-tags
6994
6995
  // except for `</dt>` or `</thead>`, end tags may be omitted if no more content in parent element
6995
- if (tag && optionalEndTag && optionalEndTagEmitted && !trailingElements.has(optionalEndTag) && (optionalEndTag !== 'p' || !pInlineElements.has(tag))) {
6996
+ if (tag && optionalEndTag && optionalEndTagEmitted && !trailingElements.has(optionalEndTag) && (optionalEndTag !== 'p' || (!pInlineElements.has(tag) && !tag.includes('-')))) {
6996
6997
  removeEndTag();
6997
6998
  }
6998
6999
  optionalEndTag = optionalEndTags.has(tag) ? tag : '';
@@ -1 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OAAO;;;;;;;gCAOP,OAAO;;;;;;;;iCAMP,OAAO;;;;;;;;;;qBAOP,MAAM,EAAE;;;;;;;qBASR,IAAI,GAAG,GAAG;;;;;;;4BAMV,OAAO;;;;;;;;qBAMP,OAAO;;;;;;;;;4BAOP,OAAO,GAAG,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;;;;;;;;0BAQtD,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;gCAOP,MAAM,EAAE;;;;;;;;yBAyBR,OAAO;;;;;;;;gCAOP,OAAO;;;;;;;iCAOP,OAAO;;;;;;;oCAMP,OAAO;;;;;;;;;;0BAMP,OAAO;;;;;;;;;qBASP,OAAO,GAAG,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,IAAI,CAAC;;;;;;;;;qBAQzD,OAAO,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;;;;;;;;0BAQrC,OAAO;;;;;;;sBAOP,OAAO;;wBAjnBkC,cAAc;0BAAd,cAAc;+BAAd,cAAc"}
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "lightningcss": "^1.31.1",
11
11
  "terser": "^5.46.0"
12
12
  },
13
- "description": "Super-configurable, well-tested, JavaScript-based HTML minifier (enhanced successor of HTML Minifier)",
13
+ "description": "Super-configurable, well-tested, JavaScript-based HTML minifier (enhanced successor of HTML Minifier).",
14
14
  "devDependencies": {
15
15
  "@commitlint/cli": "^20.3.1",
16
16
  "@eslint/js": "^9.39.2",
@@ -19,7 +19,7 @@
19
19
  "@rollup/plugin-node-resolve": "^16.0.3",
20
20
  "@swc/core": "^1.15.11",
21
21
  "eslint": "^9.39.2",
22
- "rollup": "^4.55.1",
22
+ "rollup": "^4.57.1",
23
23
  "rollup-plugin-polyfill-node": "^0.13.0",
24
24
  "typescript": "^5.9.3",
25
25
  "vite": "^7.3.1"
@@ -94,5 +94,5 @@
94
94
  },
95
95
  "type": "module",
96
96
  "types": "./dist/types/htmlminifier.d.ts",
97
- "version": "5.0.3"
97
+ "version": "5.0.5"
98
98
  }
@@ -1200,9 +1200,10 @@ async function minifyHTML(value, options, partialMarkup) {
1200
1200
  optionalStartTag = '';
1201
1201
  // `</html>` or `</body>` may be omitted if not followed by comment
1202
1202
  // `</head>` may be omitted if not followed by space or comment
1203
- // `</p>` may be omitted if no more content in non-`</a>` parent
1203
+ // `</p>` may be omitted if no more content in parent, unless parent is in `pInlineElements` or is a custom element
1204
+ // https://html.spec.whatwg.org/multipage/syntax.html#optional-tags
1204
1205
  // except for `</dt>` or `</thead>`, end tags may be omitted if no more content in parent element
1205
- if (tag && optionalEndTag && optionalEndTagEmitted && !trailingElements.has(optionalEndTag) && (optionalEndTag !== 'p' || !pInlineElements.has(tag))) {
1206
+ if (tag && optionalEndTag && optionalEndTagEmitted && !trailingElements.has(optionalEndTag) && (optionalEndTag !== 'p' || (!pInlineElements.has(tag) && !tag.includes('-')))) {
1206
1207
  removeEndTag();
1207
1208
  }
1208
1209
  optionalEndTag = optionalEndTags.has(tag) ? tag : '';