Created
February 28, 2011 00:08
-
-
Save defunkt/846723 to your computer and use it in GitHub Desktop.
Print the size of a minified & gzip'd js file.
This file contains 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
#!/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