[Question] [JSCodeGen] Remove unused Classes / Variables

Issue #241 new
Toky Olivier Razanakotonarivo created an issue

Hello @egrange,

Can you tell please how to tell the codegen to remove unused classes/records/variables from the generated JS file. It’s to get the tiniest file size possible for the generated JS file?

Thank you so much

Comments (2)

  1. Eric Grange repo owner

    You can reduce file size by using the codegen options cgoSmartLink and cgoDeVirtualize.

    The cgoObfuscate & cgoOptimizeForSize option can be used as well to reduce variable names in length as well as redundant whitespace.
    If it’s for a final build, the best results can be achieved by passing the JS to Google’s Closure Compiler, on top of cgoSmartLink and cgoDeVirtualize (obfuscation & optimize for size are less relevant when going through the closure compiler).

    Another important point is to disable RTTI (with cgoNoRTTI) otherwise a lot of classes will be pulled in, even if unused, because they could be instantiated dynamically through RTTI.

  2. Log in to comment