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

--preload-file is more efficient than --embed-file #165

Closed
satoshinm opened this issue May 28, 2017 · 1 comment
Closed

--preload-file is more efficient than --embed-file #165

satoshinm opened this issue May 28, 2017 · 1 comment
Labels
Milestone

Comments

@satoshinm
Copy link
Owner

http://kripken.github.io/emscripten-site/docs/tools_reference/emcc.html#emcc-embed-file says "Embedding files is much less efficient than preloading them", and indeed it generates a huge JavaScript array in craft.js even in the release build:

var Module;if(typeof Module==="undefined")Module={};if(!Module.expectedDataFileDownloads){Module.expectedDataFileDownloads=0;Module.finishedDataFileDownloads=0}Module.expectedDataFileDownloads++;((function(){var loadPackage=(function(metadata){function runWithFS(){Module"FS_createPath";Module"FS_createPath";var fileData0=[];fileData0.push.apply(fileData0,[35,105,102,100,101,102,32,71,76,95,69,83,10,112,114,101,99,105,115,105,111,110,32,109,101,100,105,117,109,112,32,102,108,111,97,116,59,10,112,114,101,99,105,115,105,111,110,32,109,101,100,105,117,109,112,32,105,110,116,59,10,35,101,110,100,105,102,10,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,1...

Should switch to --preload-file, and include the extra .data file

@satoshinm
Copy link
Owner Author

A nice space savings, before:

release-build-js $ ls -lh craft.*
-rw-r--r--  1 admin  staff   101K May 27 17:58 craft.html
-rw-r--r--  1 admin  staff    19K May 27 17:58 craft.html.mem
-rw-r--r--  1 admin  staff   1.4M May 27 17:58 craft.js

after:

release-build-js $ ls -lh craft.*
-rw-r--r--  1 admin  staff   241K May 27 18:00 craft.data
-rw-r--r--  1 admin  staff   101K May 27 18:00 craft.html
-rw-r--r--  1 admin  staff    19K May 27 18:00 craft.html.mem
-rw-r--r--  1 admin  staff   624K May 27 18:00 craft.js

624 + 241 = 865 KB, less than the 1.4 MB craft.js from before due to inefficient encoding

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant