I finished compiling our app with js_of_ocaml, and now would like to reduce the size of its output significantly. The output is currently 3.2MB, and I managed to reduce it to 2.4MB, but now i’m stuck.
The main things I’ve already done:
- removed a lot of the ppx_derivers, especially ppx_bin_prot, which saved about 800KB (derivers like show, eq, compare, sexp, etc, saved about 20kb each after I removed them).
--setenv FORCE_DROP_INLINE_TEST=true(saved about 170k)
- removed any runtime js files I could
Here’s things I tried which didn’t make much difference:
--opt 3(maybe 10KB difference)
--disable debugger: no difference
(link_flags (-linkall)): made it a little bit bigger
- tried running ocamlclean on the bytecode, but it didnt work (we’re using ocaml 4.07, and got the error “Error: invalid bytecode file (magic string does not match)”)
--no-inline: made it 300k bigger, unsurprisingly
Has anyone got advice on how to approach this?
PS: There are our dune files, using dune 1.1.1: