Browse Source

use closure compiler for initjs, for now; print out initjs sizes for comparison

pull/2/head
Sami Vaarala 11 years ago
parent
commit
3af1dc4fdc
  1. 8
      src/duk_initjs.js
  2. 31
      util/make_dist.sh

8
src/duk_initjs.js

@ -5,10 +5,10 @@
* compatible for user code when core features are changed, without burdening
* the main C code with compatibility stuff.
*
* This file goes through UglifyJS to minify it. UglifyJS renames variables,
* removes comments, and is clever enough to drop any "if (false) { ... }"
* blocks altogether, so that's an effective way to disable currently unneeded
* code.
* This file is minified with UglifyJS or the closure compiler. Both will
* rename variables, remove comments, and are clever enough to drop any
* "if (false) { ... }" blocks altogether, so that's an effective way to
* disable currently unneeded code.
*/
(function(G, D) {

31
util/make_dist.sh

@ -211,14 +211,31 @@ for i in \
done
# Initjs code: built-in Ecmascript code snippets which are evaluated when
# a new global context is created. UglifyJS is used to compact the source,
# not to obfuscate it (although that happens as an unwanted side effect).
# a new global context is created. UglifyJS or the closure compiler is
# used to compact the source. Obfuscating the code is not a goal, although
# that happens as an unwanted side effect.
#
# Closure compiler --compilation_level ADVANCED_OPTIMIZATIONS breaks some
# of the existing code, so don't use it.
cat \
src/duk_initjs.js \
cat src/duk_initjs.js \
| UglifyJS/bin/uglifyjs --ascii --no-dead-code --no-copyright \
> $DISTSRCSEP/duk_initjs_min.js.tmp
cp $DISTSRCSEP/duk_initjs_min.js.tmp $DISTSRCSEP/duk_initjs_min.js
> $DISTSRCSEP/duk_initjs_uglify.js.tmp
java -jar compiler.jar \
--warning_level QUIET \
--language_in ECMASCRIPT5 \
--compilation_level SIMPLE_OPTIMIZATIONS \
src/duk_initjs.js \
> $DISTSRCSEP/duk_initjs_closure.js.tmp
INITJS_ORIG=`wc -c < src/duk_initjs.js`
INITJS_UGLIFY=`wc -c < $DISTSRCSEP/duk_initjs_uglify.js.tmp`
INITJS_CLOSURE=`wc -c < $DISTSRCSEP/duk_initjs_closure.js.tmp`
echo "Minified initjs size: original=$INITJS_ORIG, UglifyJS=$INITJS_UGLIFY, closure=$INITJS_CLOSURE"
# choose which minifier to use
#echo "Using UglifyJS minified version"; cp $DISTSRCSEP/duk_initjs_uglify.js.tmp $DISTSRCSEP/duk_initjs_min.js
echo "Using closure minified version"; cp $DISTSRCSEP/duk_initjs_closure.js.tmp $DISTSRCSEP/duk_initjs_min.js
# Autogenerated strings and built-in files
#
@ -234,7 +251,7 @@ python src/genbuildparams.py \
python src/genbuiltins.py \
--buildinfo=$DISTSRCSEP/buildparams.json.tmp \
--initjs-data=$DISTSRCSEP/duk_initjs_min.js.tmp \
--initjs-data=$DISTSRCSEP/duk_initjs_min.js \
--out-header=$DISTSRCSEP/duk_builtins.h \
--out-source=$DISTSRCSEP/duk_builtins.c \

Loading…
Cancel
Save