bevy
bevy copied to clipboard
Too large WebAssembly bin file
What problem does this solve or what need does it fill?
Trivial example 2d_rect weights 13MB.

Playing with optimization options I reached ~4 MB. Still that's too much. Is that possible to get less than 0.5 MB?
What solution would you like?
Excluding some features?
Putting naga under a feature?
More features?
You may want to try using this
[dependencies.bevy]
version = "0.6"
default-features = false
features = [
"bevy_sprite",
"bevy_render"
]
in your cargo manifest.
This will remove all the "bloat" from bevy and should optimize size of the binary.
Also for the size over the network: gzip makes a huge difference (something like 14mb -> 3-4mb). You can also try removing debug info and running wasm-opt: https://rustwasm.github.io/book/reference/code-size.html
https://github.com/WebAssembly/binaryen is the current state of the art to optimise wasm.
The example page is using a release build without extra optimisations and the same features for all examples, so it can't be reduced to a minimal set. Luckily it's hosted by GitHub with a properly configured host for compression, and a CDN.
https://github.com/bevyengine/bevy/discussions/14864