Are you building will all optimization options turned to 11? Usually Emscripten is very good at aggressive dead code elimination, both on the WASM and JS side. Some things to check in the build settings to minimize build size (I'm not 100% sure how many of those are still needed versus having become the default now):
- turn off filesystem support if you don't need it: -s NO_FILESYSTEM=1 (linker setting)
- enabling LTO may help with more aggressive DCE, but also causes more aggressive inlining: -flto (compile and linker setting)
- enable the Closure JS minifier: --closure (linker setting)
- enable minimal runtime -s MINIMAL_RUNTIME=2 -s ENVIRONMENT=web
- test the various optimization settings that trade off speed vs size (-O2 vs -Os vs -Oz)
Finally if you are looking for a more minimal GLFW/SDL replacement, check out sokol_app.h. This has fewer features than GLFW or SDL for desktop platforms, but is a fairly complete alternative for WASM applications:
Cheers!