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

Wasm file size #3978

Closed
caperaven opened this issue Feb 18, 2022 · 2 comments
Closed

Wasm file size #3978

caperaven opened this issue Feb 18, 2022 · 2 comments
Labels
C-Docs An addition or correction to our documentation C-Performance A change motivated by improving speed, memory usage or compile times O-Web Specific to web (WASM) builds

Comments

@caperaven
Copy link

What problem does this solve or what need does it fill?

I had a look at the bevy examples on the web and it seems like the wasm file is rather bit.
I was wondering if there is a way / pattern to reduce the binary.
I am still in the evaluation phase, but bevy shows a lot of promise for, just need to trim that wasm file.

What solution would you like?

Documentation on how to best optimize for the web.

@caperaven caperaven added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Feb 18, 2022
@jakobhellermann
Copy link
Contributor

jakobhellermann commented Feb 18, 2022

There are some tips about optimizing wasm size in the unofficial bevy cheatbook.
The short version:

  • use some options to optimize more in release mode (opt-level = 's', lto = 'thin')
  • use wasm-opt to optimize further (and remove debug info if you want that)
  • serve the file compressed (this makes a huge difference!)
# default options
17M	3d_scene.wasm
12M	3d_scene.wasm.strip
9,9M	3d_scene.wasm.strip.wasm-opt
2,7M	3d_scene.wasm.strip.wasm-opt.gzip
1,7M	3d_scene.wasm.strip.wasm-opt.brotli

# lto = "thin", opt-level = "s"
15M	3d_scene_lto+s.wasm
9,6M	3d_scene_lto+s.wasm.strip
7,6M	3d_scene_lto+s.wasm.strip.wasm-opt
2,1M	3d_scene_lto+s.wasm.strip.wasm-opt.gzip
1,4M	3d_scene_lto+s.wasm.strip.wasm-opt.brotli

@alice-i-cecile alice-i-cecile added C-Docs An addition or correction to our documentation C-Performance A change motivated by improving speed, memory usage or compile times O-Web Specific to web (WASM) builds and removed C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Feb 18, 2022
@alice-i-cecile
Copy link
Member

Closing as a duplicate of #3800.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Docs An addition or correction to our documentation C-Performance A change motivated by improving speed, memory usage or compile times O-Web Specific to web (WASM) builds
Projects
None yet
Development

No branches or pull requests

3 participants