UglifyJS/test/compress/reorder-funs.js
Geraint f8dd879873 "reorder_funs" - sort function declarations by complexity
This reduces the size after gzip.  Complexity is (for now) measured simply by counting AST nodes.
2016-06-28 15:56:25 +01:00

33 lines
954 B
JavaScript

reorder_functions_after_optimize: {
options = {
collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true,
comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true,
reorder_funs:true, keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true
}
input: {
function longFun(x, y) {
return [x, y].map(function (x) {
return x*x;
});
}
function medFun(x) {
return 15*x;
}
function shortFun() {
return 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10;
}
}
expect: {
function shortFun() {
return 55;
}
function medFun(x) {
return 15*x;
}
function longFun(x, y) {
return [x, y].map(function (x) {
return x*x;
});
}
}
}