Repository navigation
v1.0.1
Performance
This release makes parsing and queries faster, and makes the parsed tree smaller. The API does not change.
Results on 12 real pages (4.79 MB), with Bun 1.4.4 and Node 26.12.1 on an Apple M1 Max:
| Workload | Bun | Node |
|---|---|---|
parse() |
11.8ms → 7.9ms | 12.5ms → 11.7ms |
parse() + query |
18.2ms → 11.8ms | 22.3ms → 16.3ms |
mutable.parse() |
14.0ms → 10.3ms | 26.1ms → 13.1ms |
mutable parse + stringify |
13.7ms → 10.0ms | 15.2ms → 13.5ms |
mutable parse + edit + stringify |
33.4ms → 27.8ms | 44.1ms → 35.5ms |
The parsed trees of the corpus now hold 4.9 MB of memory on Node, down from 5.5 MB. With @lukeed/html/mutable, they hold 20.9 MB, down from 22.1 MB.
Changes
getAttr(),hasAttr(), and selectors read attributes from a flat list. The frozenattributesrecord is built only when you read it. (41e8b5e)- The parser finds the end of a tag with a character loop, not a regex. (f5fc7f7)
- The tree is stored in typed arrays. (8363b0d)
- Common tag names are shared strings, so the parser makes no new string for each tag. (b17dbbf, bbe5916)
- Internal caches are sized to the tree, so the engine keeps them in fast storage. (2e20ce9)
- Each tag needs one lookup for its parse rules, not up to five. (9cac437)
Notes
- The bundle is 0.7 kB larger: 5.9 kB gzip for
@lukeed/htmland 7.1 kB for@lukeed/html/mutable. - If you read
attributeson every element, the tree holds a little more memory than before, because it keeps the list and the record.getAttr()does not have this cost.
Full Changelog: v1.0.0...v1.0.1