Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

please rewrite sheetjs with es2015+ syntax #2085

Closed
anlexN opened this issue Aug 14, 2020 · 2 comments
Closed

please rewrite sheetjs with es2015+ syntax #2085

anlexN opened this issue Aug 14, 2020 · 2 comments

Comments

@anlexN
Copy link

anlexN commented Aug 14, 2020

i review sheetjs source code one line by one line, i think if it is written by es2015+, sheetjs size will be decreased by about 30%

@beeing
Copy link

beeing commented Jul 9, 2021

Perhaps typescript would be better option? Would be interested to have a smaller bundle.

image

We can get more mileage if we focus on the cpexcel as its the largest part.

Noticed the cpexcel.js can probably be reduced in size as there's many repeated strings like we can have the common prefix as separate variable.

Below constant is repeated 31 times, which can reduce about 8K characters.

\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t\n\u000b\f\r\u000e\u000f\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~

The below scripts can be created as factory / common functions

Below is called 26 times - can reduce about 4K

, D = [], e = {}; for(var i=0;i!=d.length;++i) { if(d.charCodeAt(i) !== 0xFFFD) e[d.charAt(i)] = i; D[i] = d.charAt(i); } return {"enc": e, "dec": D }; })();

Below have 468 calls to it - about 50K reduction

for(j = 0; j != D[185].length; ++j) if(D[185][j].charCodeAt(0) !== 0xFFFD) { e[D[185][j]] = 47360 + j; d[47360 + j] = D[185][j];}

The above 3 combined, we can easily shave off 60K+ characters from the script.

I think the above should be still maintaining the readability of the current code.

@SheetJSDev
Copy link
Contributor

@beeing the issue of a smaller codepage dependency will be tracked in the codepage repo

Preliminary ESM support has been pushed and some tree shaking is possible.

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

No branches or pull requests

3 participants