html-minifier-next 4.16.3 → 4.16.4

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.
Files changed (3) hide show
  1. package/README.md +58 -5
  2. package/package.json +7 -3
  3. package/src/utils.js +0 -11
package/README.md CHANGED
@@ -359,21 +359,20 @@ How does HTML Minifier Next compare to other minifiers? (All minification with t
359
359
  | --- | --- | --- | --- | --- | --- | --- | --- |
360
360
  | [A List Apart](https://alistapart.com/) | 59 | **50** | 51 | 52 | 51 | 54 | 52 |
361
361
  | [Apple](https://www.apple.com/) | 211 | **176** | 187 | 189 | 190 | 191 | 192 |
362
- | [BBC](https://www.bbc.co.uk/) | 686 | **624** | 643 | 644 | 645 | 680 | n/a |
362
+ | [BBC](https://www.bbc.co.uk/) | 712 | **649** | 669 | 669 | 671 | 707 | n/a |
363
363
  | [CERN](https://home.cern/) | 152 | **83** | 91 | 91 | 91 | 93 | 96 |
364
364
  | [CSS-Tricks](https://css-tricks.com/) | 162 | **119** | 127 | 143 | 143 | 148 | 144 |
365
365
  | [ECMAScript](https://tc39.es/ecma262/) | 7250 | **6401** | 6573 | 6455 | 6578 | 6626 | n/a |
366
366
  | [EDRi](https://edri.org/) | 80 | **59** | 70 | 70 | 71 | 75 | 73 |
367
367
  | [EFF](https://www.eff.org/) | 54 | **45** | 49 | 47 | 48 | 49 | 49 |
368
368
  | [European Alternatives](https://european-alternatives.eu/) | 48 | **30** | 32 | 32 | 32 | 32 | 32 |
369
- | [FAZ](https://www.faz.net/aktuell/) | 1587 | 1476 | **1421** | 1511 | 1522 | 1533 | n/a |
369
+ | [FAZ](https://www.faz.net/aktuell/) | 1576 | 1466 | **1412** | 1500 | 1511 | 1522 | n/a |
370
370
  | [French Tech](https://lafrenchtech.gouv.fr/) | 153 | **122** | 126 | 126 | 126 | 132 | 127 |
371
371
  | [Frontend Dogma](https://frontenddogma.com/) | 225 | **217** | 238 | 223 | 225 | 244 | 225 |
372
372
  | [Google](https://www.google.com/) | 18 | **16** | 17 | 17 | 17 | 18 | 18 |
373
- | [Ground News](https://ground.news/) | 2291 | **2005** | 2106 | 2136 | 2139 | 2278 | n/a |
373
+ | [Ground News](https://ground.news/) | 2374 | **2094** | 2186 | 2211 | 2213 | 2361 | n/a |
374
374
  | [HTML Living Standard](https://html.spec.whatwg.org/multipage/) | 149 | 148 | 153 | **147** | 149 | 155 | 149 |
375
375
  | [Igalia](https://www.igalia.com/) | 50 | **33** | 36 | 36 | 36 | 37 | 37 |
376
- | [Leanpub](https://leanpub.com/) | 235 | **205** | 220 | 219 | 220 | 230 | 232 |
377
376
  | [Mastodon](https://mastodon.social/explore) | 37 | **28** | 32 | 35 | 35 | 36 | 36 |
378
377
  | [MDN](https://developer.mozilla.org/en-US/) | 109 | **62** | 64 | 65 | 65 | 68 | 68 |
379
378
  | [Middle East Eye](https://www.middleeasteye.net/) | 223 | **197** | 203 | 201 | 201 | 202 | 203 |
@@ -387,7 +386,7 @@ How does HTML Minifier Next compare to other minifiers? (All minification with t
387
386
  | [United Nations](https://www.un.org/en/) | 152 | **112** | 121 | 125 | 125 | 130 | 123 |
388
387
  | [Vivaldi](https://vivaldi.com/) | 92 | **74** | n/a | 79 | 81 | 83 | 81 |
389
388
  | [W3C](https://www.w3.org/) | 51 | **36** | 39 | 38 | 38 | 41 | 39 |
390
- | **Average processing time** | | 100 ms (30/30) | 157 ms (29/30) | 52 ms (30/30) | **14 ms (30/30)** | 278 ms (30/30) | 1385 ms (24/30) |
389
+ | **Average processing time** | | 96 ms (29/29) | 160 ms (28/29) | 52 ms (29/29) | **14 ms (29/29)** | 282 ms (29/29) | 1766 ms (23/29) |
391
390
 
392
391
  (Last updated: Dec 27, 2025)
393
392
  <!-- End auto-generated -->
@@ -552,6 +551,44 @@ ignoreCustomFragments: [/\{\{[\s\S]{0,500}?\}\}/]
552
551
 
553
552
  **Important:** When using custom `ignoreCustomFragments`, the minifier automatically applies bounded quantifiers to prevent ReDoS attacks, but you can also write safer patterns yourself using explicit bounds.
554
553
 
554
+ #### Escaping patterns in different contexts
555
+
556
+ The escaping requirements for `ignoreCustomFragments` patterns differ depending on how you’re using HMN:
557
+
558
+ **Config file (JSON):**
559
+
560
+ ```json
561
+ {
562
+ "ignoreCustomFragments": ["\\{%[\\s\\S]{0,1000}?%\\}", "\\{\\{[\\s\\S]{0,500}?\\}\\}"]
563
+ }
564
+ ```
565
+
566
+ **Programmatic (JavaScript/Node.js):**
567
+
568
+ ```javascript
569
+ ignoreCustomFragments: [/\{%[\s\S]{0,1000}?%\}/, /\{\{[\s\S]{0,500}?\}\}/]
570
+ ```
571
+
572
+ **CLI (via config file—recommended):**
573
+
574
+ ```shell
575
+ html-minifier-next --config-file=config.json input.html
576
+ ```
577
+
578
+ **CLI (inline—not recommended due to complex escaping):**
579
+
580
+ ```shell
581
+ html-minifier-next --ignore-custom-fragments '[\\\"\\\\{%[\\\\s\\\\S]{0,1000}?%\\\\}\\\"]' input.html
582
+ ```
583
+
584
+ For CLI usage, using a config file is strongly recommended to avoid complex shell and JSON escaping.
585
+
586
+ **[Web demo:](https://j9t.github.io/html-minifier-next/)**
587
+
588
+ ```
589
+ \{%[\s\S]{0,1000}?%\} \{\{[\s\S]{0,500}?\}\}
590
+ ```
591
+
555
592
  ## Running HTML Minifier Next locally
556
593
 
557
594
  ### Local server
@@ -572,6 +609,22 @@ npm run benchmarks
572
609
 
573
610
  (In case of dependency conflicts, run `npm i` with the `--legacy-peer-deps` flag.)
574
611
 
612
+ ### Regression tests
613
+
614
+ ```shell
615
+ cd benchmarks;
616
+ npm i;
617
+ npm run backtest
618
+ ```
619
+
620
+ The backtest tool tracks minification performance across Git history. Results are saved in `benchmarks/backtest/` as CSV and JSON files.
621
+
622
+ Parameters:
623
+
624
+ * No argument: Tests last 50 commits (default)
625
+ * `COUNT`: Tests last `COUNT` commits (e.g., `npm run backtest 100`)
626
+ * `COUNT/STEP`: Tests last `COUNT` commits, sampling every `STEP`th commit (e.g., `npm run backtest 500/10` tests 50 commits)
627
+
575
628
  ## Acknowledgements
576
629
 
577
630
  With many thanks to all the previous authors of HTML Minifier, especially [Juriy “kangax” Zaytsev](https://github.com/kangax), and to everyone who helped make this new edition better, particularly [Daniel Ruf](https://github.com/DanielRuf) and [Jonas Geiler](https://github.com/jonasgeiler).
package/package.json CHANGED
@@ -23,7 +23,7 @@
23
23
  "@rollup/plugin-terser": "^0.4.4",
24
24
  "@swc/core": "^1.15.7",
25
25
  "eslint": "^9.39.2",
26
- "rollup": "^4.53.3",
26
+ "rollup": "^4.54.0",
27
27
  "rollup-plugin-polyfill-node": "^0.13.0",
28
28
  "typescript": "^5.9.3",
29
29
  "vite": "^7.2.7"
@@ -42,6 +42,7 @@
42
42
  "dist/",
43
43
  "src/"
44
44
  ],
45
+ "funding": "https://buymeacoffee.com/meiert",
45
46
  "homepage": "https://j9t.github.io/html-minifier-next/",
46
47
  "keywords": [
47
48
  "cli",
@@ -78,7 +79,10 @@
78
79
  "optional": true
79
80
  }
80
81
  },
81
- "repository": "https://github.com/j9t/html-minifier-next.git",
82
+ "repository": {
83
+ "type": "git",
84
+ "url": "git+https://github.com/j9t/html-minifier-next.git"
85
+ },
82
86
  "scripts": {
83
87
  "prebuild": "node --eval='require(`fs`).rmSync(`dist`,{recursive:true,force:true})'",
84
88
  "build": "tsc && rollup -c",
@@ -93,5 +97,5 @@
93
97
  "test:watch": "node --test --watch tests/*.spec.js"
94
98
  },
95
99
  "type": "module",
96
- "version": "4.16.3"
100
+ "version": "4.16.4"
97
101
  }
package/src/utils.js DELETED
@@ -1,11 +0,0 @@
1
- export async function replaceAsync(str, regex, asyncFn) {
2
- const promises = [];
3
-
4
- str.replace(regex, (match, ...args) => {
5
- const promise = asyncFn(match, ...args);
6
- promises.push(promise);
7
- });
8
-
9
- const data = await Promise.all(promises);
10
- return str.replace(regex, () => data.shift());
11
- }