Skip to content

Reduce bundle size by compressing conversion tables - #70

Merged
polygonplanet merged 4 commits into
masterfrom
feature/compress-tables
Oct 3, 2026
Merged

polygonplanet merged 4 commits into
masterfrom
feature/compress-tables

Conversation

@polygonplanet

Copy link
Copy Markdown
Owner

Store the UTF-8 to JIS conversion tables in a compressed text format and expand them on the first call to convert().

The tables are expanded lazily only when a conversion is actually needed, rather than at module load time, to avoid unnecessary initialization overhead.

Before After
encoding.js 304 KB 148 KB
encoding.min.js 229 KB 88 KB
encoding.min.js (gzip) 76 KB 39 KB

The first encode now has an extra step to expand the tables, but loading is faster because the tables are much smaller, so load + first conversion is faster overall.
For decoding, expanding the tables takes about as long as the previous init_JIS_TO_UTF8_TABLE() did, even though it now builds both directions at once.

Conversion results are unchanged.

@polygonplanet
polygonplanet merged commit 3f992e1 into master Oct 3, 2026
18 checks passed
@polygonplanet
polygonplanet deleted the feature/compress-tables branch October 3, 2026 17:29
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.

1 participant