Skip to content

Instantly share code, notes, and snippets.

@theasta
Created October 5, 2014 22:38
Show Gist options
  • Save theasta/f8786b3b56fbb36fb995 to your computer and use it in GitHub Desktop.
Save theasta/f8786b3b56fbb36fb995 to your computer and use it in GitHub Desktop.
Compare js file size before and after minification with uglifyJS2
function comparejsmin() {
local origsize=$(wc -c < "$1")
local uglifysize=$(uglifyjs "$1" | wc -c)
local ratio=$(echo "$uglifysize * 100/ $origsize" | bc -l)
printf "Unminified file: %d bytes\n" "$origsize"
printf "Minified file: %d bytes (%2.2f%%)\n" "$uglifysize" "$ratio"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment