esmangle
esmangle copied to clipboard
change top-level variable declarations with initialiser to assignments
var a = 0;
can become
a=0
at program level. Any assignment to a non-computed member access on this at program level can be similarly transformed:
this.a = 0;
can become
a=0
When the script is strict code, it becomes ReferenceError.
'use strict';
Hello = 42; // ReferenceError
So we cannot apply this to strict code, and as the result, I think this optimization rarely works. Do you think about this?
I'm sure the vast majority of top-level code is not in strict mode.