This might seem like a stupid question but is there some reason why Uglifiers don't uglify references to external functions using a pointer?
An example:
A file I'm working on has multiple calls to _gaq.push()
. I've squished this by adding to the top of the file var _g=_gaq.push();
. I then update the 12 calls to it to use the _g
pointer. This hasn't saved a huge amount (84 bytes) but every little helps right?
Am I missing something, is there a reason Uglifiers don't do this?
In short, because there is too much potential for the code to break.
Assuming you mean
var _g=_gaq.push;
, then two possible causes of breakage spring to mind:this
insidepush
. If the functionality ofpush
depends on that, then you just broke it._gaq.push
is changed after you assign it to_g
then your code would continue to operate on the old value.