Closed jxom closed 9 months ago
Ah, oops, that init()
is not supposed to be there. The new 1.10 release should have on-demand loading as you describe. I'll fix this before I release the final 1.10 update with the Unicode 15.1.0 changes (sometime before end of week.)
Thank you!
The latest npm release 1.10.0 has the delayed init feature.
I investigated the init code a bit and made a few minor optimizations. I'm seeing about ~200ms on weak hardware. If this is still an issue, this can be significantly faster with a different data structure. Additionally, the init could be delayed for specific ASCII input.
I was able to reduce it down to about 140ms on the same hardware. With a Set
that uses intervals, it's under 100ms. I'll revisit this when I push the next round of compression changes.
It seems when I synchronously import
@adraffy/ens-normalize
, it causes some preparation side-effects to run: https://github.com/adraffy/ens-normalize.js/blob/main/src/lib.js#L172This causes a pretty large performance hit (especially on webpages for first load time).
Wonder if it could be possible to instead export the
init
function so folks can choose to eagerly initialize/prepare, and if it hasn't been prepared at time of fn call (e.g.normalize_ens
) then runinit
?