Last active
December 10, 2015 08:38
-
-
Save trygve-lie/4408672 to your computer and use it in GitHub Desktop.
Uglify seems to not rewrite object keys which is never exposed publicly. In this example the key "veryLongKeyName" could have been rewritten too something shorter without any danger. Uglify 2.2.1 command used:
uglifyjs file.js --output file.min.js --compress dead-code=true,unsafe=true,unused=true --mangle sort=true
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// After minification | |
function Foo(){ | |
var e = { | |
veryLongKeyName:!0 | |
}; | |
function n(){ | |
return e.veryLongKeyName | |
} | |
return{ | |
publicMethod:function(){ | |
return n() | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Before minification | |
function Foo() { | |
var veryLongObjectName = { | |
veryLongKeyName : true | |
} | |
function veryLongFunctionName() { | |
return veryLongObjectName.veryLongKeyName; | |
} | |
return { | |
publicMethod : function() { | |
return veryLongFunctionName(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment