html-minifier-next 6.2.8 → 6.2.9
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 +35 -1
- package/dist/htmlminifier.cjs +882 -557
- package/dist/types/htmlminifier.d.ts +77 -60
- package/dist/types/htmlminifier.d.ts.map +1 -1
- package/dist/types/htmlparser.d.ts +19 -3
- package/dist/types/htmlparser.d.ts.map +1 -1
- package/dist/types/lib/attributes.d.ts +137 -23
- package/dist/types/lib/attributes.d.ts.map +1 -1
- package/dist/types/lib/content.d.ts +37 -5
- package/dist/types/lib/content.d.ts.map +1 -1
- package/dist/types/lib/elements.d.ts +29 -4
- package/dist/types/lib/elements.d.ts.map +1 -1
- package/dist/types/lib/options.d.ts +17 -14
- package/dist/types/lib/options.d.ts.map +1 -1
- package/dist/types/lib/utils.d.ts +28 -11
- package/dist/types/lib/utils.d.ts.map +1 -1
- package/dist/types/lib/whitespace.d.ts +40 -6
- package/dist/types/lib/whitespace.d.ts.map +1 -1
- package/dist/types/tokenchain.d.ts +17 -3
- package/dist/types/tokenchain.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/htmlminifier.js +405 -346
- package/src/htmlparser.js +101 -48
- package/src/lib/attributes.js +166 -50
- package/src/lib/content.js +28 -12
- package/src/lib/elements.js +30 -7
- package/src/lib/options.js +55 -42
- package/src/lib/utils.js +26 -7
- package/src/lib/whitespace.js +30 -11
- package/src/presets.js +1 -1
- package/src/tokenchain.js +30 -17
package/README.md
CHANGED
|
@@ -567,6 +567,8 @@ For CLI usage, using a config file is strongly recommended to avoid complex shel
|
|
|
567
567
|
|
|
568
568
|
## Working on HTML Minifier Next
|
|
569
569
|
|
|
570
|
+
Note: This section assumes working with main dependencies installed (`npm i`).
|
|
571
|
+
|
|
570
572
|
### Local server
|
|
571
573
|
|
|
572
574
|
```shell
|
|
@@ -581,7 +583,7 @@ npm i;
|
|
|
581
583
|
npm run backtest
|
|
582
584
|
```
|
|
583
585
|
|
|
584
|
-
The backtest tool tracks minification performance across Git history. Results are saved in the backtest folder as
|
|
586
|
+
The backtest tool tracks minification performance across Git history. Results are saved in the backtest folder as a JSON file, results.json.
|
|
585
587
|
|
|
586
588
|
Parameters:
|
|
587
589
|
|
|
@@ -589,6 +591,38 @@ Parameters:
|
|
|
589
591
|
* `COUNT`: Tests last `COUNT` commits (e.g., `npm run backtest 100`)
|
|
590
592
|
* `COUNT/STEP`: Tests last `COUNT` commits, sampling every `STEP`th commit (e.g., `npm run backtest 500/10` tests 50 commits)
|
|
591
593
|
|
|
594
|
+
### Working tree benchmarks
|
|
595
|
+
|
|
596
|
+
Where the backtest walks Git history, the benchmark times the code as it is _right now_—useful for A/B testing a branch against a saved baseline:
|
|
597
|
+
|
|
598
|
+
```shell
|
|
599
|
+
cd backtest;
|
|
600
|
+
npm i;
|
|
601
|
+
npm run benchmark
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
It reuses the backtest corpus (run `npm run backtest` once to download it) and reports per-file output size and median processing time.
|
|
605
|
+
|
|
606
|
+
Parameters:
|
|
607
|
+
|
|
608
|
+
* No argument: Runs and, if a baseline exists, shows size and time deltas
|
|
609
|
+
* `--save`: Saves the run as the baseline (e.g., on `main` before switching to a branch)
|
|
610
|
+
* `--core`: Disables the external minifiers (CSS, JS, SVG, URLs) to isolate HMN’s own processing time
|
|
611
|
+
* `--iterations=N`: Sets the number of timed iterations (default 5; the median is reported)
|
|
612
|
+
* `--config=PATH`: Uses an alternative options file (default `html-minifier.json`)
|
|
613
|
+
|
|
614
|
+
To compare branches (A/B run), execute `npm run benchmark -- --save` on `main`, then `npm run benchmark` on the branch to see the deltas. Add `--core` on both ends when measuring changes to HMN’s own code rather than the bundled minifiers.
|
|
615
|
+
|
|
616
|
+
#### Profiling
|
|
617
|
+
|
|
618
|
+
To profile the current working tree, run the benchmark with Node’s built-in CPU profiler:
|
|
619
|
+
|
|
620
|
+
```shell
|
|
621
|
+
node --cpu-prof benchmark.js
|
|
622
|
+
```
|
|
623
|
+
|
|
624
|
+
This writes a `.cpuprofile` file to the working directory. Load it with `npx speedscope *.cpuprofile` for a flamegraph, or drag it into Chrome DevTools → Sources → JavaScript Profiler. Compare self-time per function against a clean baseline run on `main`. Pay attention to unexpectedly heavy callbacks in hot paths—V8 de-optimization from variable object shapes or unnecessary method calls can show up there.
|
|
625
|
+
|
|
592
626
|
## Acknowledgements
|
|
593
627
|
|
|
594
628
|
With many thanks to the previous authors of and contributors to 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), [Jonas Geiler](https://github.com/jonasgeiler), and [Chris Morgan](https://github.com/chris-morgan)!
|