Open jeswr opened 1 year ago
Interesting. Were you able to improve code size even with --closure=1
and -O3
? I think we generally worry more about code size than code smells in the generated JS, since the output JS can kind of be considered machine-generated code (of course it would be nice if looked nice too)
Will double check my settings - the main code removed seemed to be unused variable declarations in the Javascript.
Yeah I think we generally rely on closure compiler to remove all of those. Or we try not to generate them in first place (by using our fake C pre-processor thing).
The current JS that emscripten generates uses some old conventions + often generates unused code; I have seen a few issues going around offering manual updates of some of these things.
I wanted to note that a combination of tools like
lebab
,eslint
androllup
could be used in a post processing step to tidy up the.js
files that emscripten emits.In particular, with the default
eslint
androllup
configs I just ran on a generated file calledswipl.js
The
out.js
was about 10% smaller on the project I tried and has various code smells removed such as limiting the use ofvar
, removing unused variables etc.