Skip to content

Instantly share code, notes, and snippets.

@defunkt
Created February 28, 2011 00:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save defunkt/846723 to your computer and use it in GitHub Desktop.
Save defunkt/846723 to your computer and use it in GitHub Desktop.
Print the size of a minified & gzip'd js file.
#!/bin/sh -e
#
# Usage: jsize file.js
# Print the size of a minified & gzip'd js file.
# e.g.
# $ jsize src/facebox.js
# 1.4K
#
# Requires uglify-js
# $ npm install uglify-js
if [ -n "$1" ]; then
f="/tmp/jsize.$RANDOM.gz"
uglifyjs -nc $1 | gzip -c - > $f
ls -lh $f | awk '{ print $5 }'
rm $f
else
cat <<usage
Usage: jsize file.js
Print the size of a minified & gzip'd js file.
Example
$ jsize src/facebox.js
1.4K
Requires uglify-js
$ npm install uglify-js
usage
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment