Skip to content

Instantly share code, notes, and snippets.

@trygve-lie
Last active December 10, 2015 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trygve-lie/4408672 to your computer and use it in GitHub Desktop.
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
// After minification
function Foo(){
var e = {
veryLongKeyName:!0
};
function n(){
return e.veryLongKeyName
}
return{
publicMethod:function(){
return n()
}
}
}
// 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