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

Open
opened 2021-09-12 20:32:44 +00:00 by SheetJSDev · 0 comments
SheetJSDev commented 2021-09-12 20:32:44 +00:00 (Migrated from github.com)

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.

Originally posted by @beeing in https://github.com/SheetJS/sheetjs/issues/2085#issuecomment-876825328

Perhaps typescript would be better option? Would be interested to have a smaller bundle. ![image](https://user-images.githubusercontent.com/28744192/125004043-36d5f680-e08b-11eb-91c0-ad6cf5e77bdf.png) 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. ```js \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 ```js , 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 ```js 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 https://github.com/SheetJS/sheetjs/issues/2085#issuecomment-876825328_
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/js-codepage#27
No description provided.