markdown-exit icon indicating copy to clipboard operation
markdown-exit copied to clipboard

Front-code the named entity table to save about 2 KiB gzip?

Open onmax opened this issue 4 weeks ago • 0 comments

Summary

Store the named entity table front-coded and export the decoder.

Motivation

character-entities is 34.9 KiB of the 98.2 KiB minified core bundle. Front-coding the sorted names, like LeftArrow and LeftArrowBar, and delta-coding the values gives the same 2,125 entries in less space.

markdown-exit/core before after change
minified 98.2 KiB 83.6 KiB -14.6 KiB
gzip 33.92 KiB 31.75 KiB -2.17 KiB

The test suite passes.

Importing the table takes 6.4 ms instead of 2.3 ms on Node 24. Unpacking it on the first named entity would avoid that for most documents. I haven't tried that yet.

Proposed Solution

Generate the packed table from character-entities at build time, and export decodeNamedEntity. Since comarkdown/comark#549, Comark reads character-entities directly to share one copy with markdown-exit, so it needs the decoder to keep sharing.

Would you take a PR?

Would you like to work on this new feature?

  • [x] I'm interested in working on this new feature

onmax avatar Nov 05 '26 19:11 onmax