Perhaps typescript would be better option? Would be interested to have a smaller bundle.
SheetJSDev opened this issue · comments
Perhaps typescript would be better option? Would be interested to have a smaller bundle.
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.
Originally posted by @beeing in SheetJS/sheetjs#2085 (comment)