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

[js/web] optimize bundle file size #9817

Merged
merged 6 commits into from
Nov 22, 2021
Merged

[js/web] optimize bundle file size #9817

merged 6 commits into from
Nov 22, 2021

Conversation

fs-eire
Copy link
Contributor

@fs-eire fs-eire commented Nov 19, 2021

Description: This change applies multiple optimizations to reduce bundle file size:

  1. use es2017 by default instead of es5 (add build target for es5 in case it's needed)
  2. introduce a compile time build flag 'BUILD_DEFS' to instruct terser to drop unnecessary code. Add check to make sure those flags are not in code for production mode.
  3. DISABLE_WASM_THREAD is defined but currently not in use yet.

file size:

608,510 ort.es5.min.js
545,529 ort.es6.min.js
538,793 ort.min.js
79,922 ort.wasm-core.min.js
152,251 ort.wasm.min.js
394,524 ort.webgl.min.js

Copy link
Contributor

@hanbitmyths hanbitmyths left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add an instruction to js/README.md?

@fs-eire
Copy link
Contributor Author

fs-eire commented Nov 22, 2021

can you add an instruction to js/README.md?

Added.

Copy link
Contributor

@hanbitmyths hanbitmyths left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work for bundle size reduction!

@fs-eire fs-eire merged commit 74ca417 into master Nov 22, 2021
@fs-eire fs-eire deleted the fs-eire/js-size-opt branch November 22, 2021 21:56
siweic0 pushed a commit to siweic0/onnxruntime-web that referenced this pull request May 9, 2024
* es2017 by default for ort-common

* add visualizer and define plugin

* es2017 for ort-web. also add build target for es5

* add multiple reduced size build for ort-web

* resolve comments, add e2e tests and add docs
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.

2 participants