Skip to content

Conversation

@ChALkeR
Copy link

@ChALkeR ChALkeR commented Dec 23, 2025

This is an ~1.85x gzipped size reduction and an ~1.27x perf improvement.

Package size, before: 236 KiB minified, 60 KiB gzipped
Package size, after: 152 KiB minified, 32.5 KiB gzipped

Bench: 230,482 -> 292,052 ops/sec

Changes done:

  1. Store ranges, statuses and mappings separately. This is good for gzip and for perf as it avoids .slice() during mapping
  2. Avoid destructuring past array length (mapping is non-existent for some status values)
  3. Delta-code everything and unpack on first use
  4. Flatten the array for storage and unpack on first use
  5. Condense repeats (almost does not affect gzip as it can do that itself, but affects on-disk size)

Further optimization is possible but I decided to stop somewhere for now

@domenic
Copy link
Member

domenic commented Dec 23, 2025

Can you reduce this to only the perf improvements? Optimizing bundle size is a non-goal for the jsdom ecosystem.

@ChALkeR
Copy link
Author

ChALkeR commented Dec 23, 2025

@domenic I can file those separately

But this package is used by far more than just jsdom, both directly and through whatwg-url:

  1. https://www.npmjs.com/package/tr46?activeTab=dependents
  2. https://www.npmjs.com/package/whatwg-url?activeTab=dependents

@domenic
Copy link
Member

domenic commented Dec 23, 2025

Sure, but, as a maintainer, I do not want to prioritize bundle size.

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.

2 participants