Last active
February 3, 2016 12:49
-
-
Save infusion/bbcd543bec900543a799 to your computer and use it in GitHub Desktop.
Closure compiler API call
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/bash | |
# A simple helper file for Google Closure compiler | |
# | |
# Copyright (c) 2011, Robert Eisele ([email protected]) | |
# Dual licensed under the MIT or GPL Version 2 licenses. | |
# Usage: ./generate.sh input.js output.js | |
curl --silent -d"compilation_level=ADVANCED_OPTIMIZATIONS&output_format=text&output_info=compiled_code" --data-urlencode "js_code@$1" \ | |
http://closure-compiler.appspot.com/compile -o x | |
gzip -9 -c x > "$2.gz" | |
mv x "$2" | |
echo "Done!" |
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/bash | |
# A simple helper file for Google Closure compiler offline version | |
# | |
# Copyright (c) 2015, Robert Eisele ([email protected]) | |
# Dual licensed under the MIT or GPL Version 2 licenses. | |
# Usage: ./cc.sh input.js | |
# Will generate input.min.js | |
if [[ "$1" == "" ]]; then | |
echo "$0 <file> [<output>]" | |
exit | |
fi | |
if [[ "$2" == "" ]]; then | |
out=${1%.*}.min.js | |
else | |
out=$2 | |
fi | |
echo "$1 > $out" | |
java -jar /Applications/closure-compiler/build/compiler.jar --compilation_level ADVANCED_OPTIMIZATIONS --js "$1" --js_output_file "$out" | |
ORIG_SIZE=$(stat -f %z "$1") | |
COMP_SIZE=$(stat -f %z "$out") | |
ORIG_GZIP=$(gzip -c -9 "$1" | wc -c | tr -d '[:space:]') | |
COMP_GZIP=$(gzip -c -9 "$out" | wc -c | tr -d '[:space:]') | |
echo " Compress: $ORIG_SIZE > $COMP_SIZE" | |
echo " GZIP: $ORIG_GZIP > $COMP_GZIP" | |
echo Done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment