[Question] [JSCodeGen] Remove unused Classes / Variables
Issue #241
new
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)
-
repo owner -
reporter Okay, thank you so much.
- Log in to comment
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.