Optimize for size over performance
If size is more important than performance, you can use
I tried with camaro and the file size reduce from 176KB down to 130KB. It’s worth a try.
Disable assertion, debug
Try adding these flags:
-s ASSERTIONS=0 and
-DNDEBUG to emcc.
emmalloc which is a smaller malloc version available in emcc by adding
-s 'MALLOC="emmalloc"' flag
--closure 1 flag may also help as well.
Remove unnecessary dependencies
Try not to import unnecessary libs in C++. Eg: don’t forget to remove
iostream if you only use it for debugging with
Emscripten has a whole section about this, do read this to stay up to date.