My approach to smaller Go wasm binaries:
- protoc-gen-go-lite: Removes dependency on reflection, making your binaries lighter.
- goweight: Analyze the size of your binaries. This is a fork with added wasm support.
- goda: Use to find why something is imported by executing:
goda graph "reach(.:all, gonum.org/v1/gonum/mat)" | dot -Tsvg -o graph.svg
- wasm-opt: Optimize wasm binaries for size with the command:
wasm-opt --enable-bulk-memory -Oz -o out.wasm in.wasm
- brotli: Compress binaries to massively reduce size; for example, from 50MB to 3MB.
- tinygo: Not fully compatible with all packages yet but shows promise for further size reduction.
Finally, here is a project template which incorporates all of the above.