Last active
August 29, 2015 14:02
-
-
Save michaek/531c83e632836a0e1ee3 to your computer and use it in GitHub Desktop.
Uglify size comparison between mangled and non-mangled variable names (using Bootstrap as example)
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
module.exports = function(grunt) { | |
grunt.loadNpmTasks('grunt-contrib-uglify'); | |
var files = [ grunt.option('js') || 'node_modules/bootstrap/js/*.js' ]; | |
grunt.initConfig({ | |
uglify: { | |
options: { | |
report: 'gzip' | |
}, | |
mangle: { | |
files: { | |
'dist/mangle.js': files | |
} | |
}, | |
no_mangle: { | |
options: { | |
mangle: false | |
}, | |
files: { | |
'dist/no_mangle.js': files | |
} | |
} | |
} | |
}); | |
grunt.registerTask('default', ['uglify:mangle', 'uglify:no_mangle']); | |
// $ grunt --no-color > output.txt | |
// $ grunt --no-color --js "some/other/js/**/*.js" > output.txt | |
} |
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
Running "uglify:mangle" (uglify) task | |
File dist/mangle.js created: 54.98 kB → 28.85 kB → 5.09 kB (gzip) | |
Running "uglify:no_mangle" (uglify) task | |
File dist/no_mangle.js created: 54.98 kB → 35.15 kB → 5.94 kB (gzip) | |
Done, without errors. |
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
{ | |
"name": "uglify-test", | |
"version": "0.0.0", | |
"description": "", | |
"main": "Gruntfile.js", | |
"dependencies": { | |
"grunt": "~0.4.5", | |
"grunt-contrib-uglify": "~0.4.0" | |
}, | |
"devDependencies": {}, | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment