Optimizing WASM File Size in Detonator 2D: A Modular Approach for Future Iterations
The WASM file size of Detonator 2D is 5.2MB, which doesn’t offer an advantage compared to the web export sizes of Godot 3 and Defold. There is hope to reduce and optimize the final output size of the WASM in future iterations of the engine. One effective approach would be to modularize larger feature sets, such as physics, animation, etc. This way, games that don’t require these features can exclude the modules, effectively optimizing the final build size.
Hello, you mean the engine WASM module size? I'm not even sure where you got the number 5.2mb since it's actually much larger than this.
Yes, making the engine modular is a possibility but it creates more build targets and more build pain as well. Before going there there are few other things to do:
- Remove extra code that is definitely not needed. For example in libsndfile contains codecs that aren't needed.
- Remove code that is only used by the editor. This is easy to do since the WASM target is already separate and there's absolutely no need to support any APIs designed for supporting editor. engine/renderer.h already does some of this conditional compilign.
- Use compiler flags to optimize for WASM size.
Thanks for reporting.
I used the game on your homepage as a reference. I believe gameengine.js is the glue code that loads and bridges the WASM, while the main part of the engine is in the WASM binary format. In other words, no matter what type of game is made, these two files are essential. FILESYSTEM should be the asset packaging format.
Your assumption about the different files is correct.
Right, I hadn't looked at the file sizes reported by the browser. Still the GameEngine.wasm file size on disk is about 16mb as of now, so the real situation is probably worse than what you see there. (Maybe the compression reduces the size that gets transferred over network that would explain the discrepancy).