Open rakudrama opened 8 years ago
I was just going to open an issue about this. There do seems to be still a lot of room for minification.
I'm currently using UglifyJS to further minify the JavaScript code already minified with dart2js, and reducing its size by an additional 10%.
You can see an example comparison here: https://gist.github.com/joseluis/e2c3c21d72e411d78d6d
112641 bytes
102947 bytes
Additional thing: the static:
property is not minified.
These changes help with some of the --fast-startup
issues:
https://github.com/dart-lang/sdk/commit/cdba92a563128bb4febcdf94270b761c23401067 - shares $defaultValues
via common base class
https://github.com/dart-lang/sdk/commit/0c83262a1e4d0977a2fd3f77202c6b358221b23c - shorter names for $requiredArgCount
, $defaultValues
, $signature
.
Still to do:
"call*"
is not yet minified.$signature
reduced to $S
but the repeated functions are not shared.$signature
entries, even when types are needed because of .runtimeType.
There are some common unminified properties in minified code.
Quick analysis of potential savings of an Angular2 + Dart app (compiled with --fast-startup)
Minify
$requiredArgCount
,$defaultValues
,$signature
: 1.64% Minifyinherit
andinstallTearOff
: 1.66%Replace most common $signature with references to shared function: 1.5% 171
$signature:function(){return{func:1,args:[,,]}}
180$signature:function(){return{func:1}}
415$signature:function(){return{func:1,args:[,]}}
Replace most common
$defaultValues:function(){return[]}
with reference to shared function: 0.62%Hopefully references to a shared function would parse faster than functions.
That is 3.3% with simply minifying helper function names and 5.4% with some other simple tricks. I don't expect that the gzipped file will be smaller. Subtract 1.66% for the standard emitter.