[Bash] Online Concatenate and Compress JavaScript Files
Concatenate and minify/compress JavaScript files via Bash script, curl, and online Google Closure Compiler.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #!/bin/bash TMPJS=/tmp/tmp.js # $1 is the directory in which js files to be processed # $2 is the minified js from online Google Closure Compiler cat $(find $1 -type f -name "*.js") > ${TMPJS} curl \ -d compilation_level=SIMPLE_OPTIMIZATIONS \ -d language=ECMASCRIPT5 \ -d output_format=text \ -d output_info=compiled_code \ --data-urlencode "js_code@${TMPJS}" \ https://closure-compiler.appspot.com/compile \ > $2 rm ${TMPJS} |
Tested on: Ubuntu Linux 16.10.
References:
[1] |
[2] | see tag of Minify HTML/CSS/JavaScript |