1 decade ago by robw00t
There's a lot of talk about impact's baking + google closure compiler:
http://impactjs.com/forums/search/closure
I've combined the two as well and have found that the google closure compiler's SIMPLE_OPTIMIZATIONS setting for compilation_level works great on impact's game.min.js file after baking.
However, as you can see here:
Example Javascript:
Compilation with SIMPLE_OPTIMIZATIONS shortens the code to this:
Compilation with ADVANCED_OPTIMIZATIONS shortens the code even further to this:
the ADVANCED_OPTIMIZATIONS flag would add a huge level of obfuscation which, for me, creates an enormous benefit in protecting the source code. Unfortunately, when I compile with ADVANCED_OPTIMIZATIONS I get an "ig is not defined" error when I run my game... *tear.
Has anyone successfully compiled against ADVANCED_OPTIMIZATIONS? If not, any chance the impact engine could be changed to support that flag?
here's the code surrounding the bug:
From Baked: (this works in chrome)
From Closure Compiler with: SIMPLE_OPTIMIZATIONS (this works in chrome)
From Closure Compiler with ADVANCED_OPTIMIZATIONS (this does not work, gives error on line 258)
http://impactjs.com/forums/search/closure
I've combined the two as well and have found that the google closure compiler's SIMPLE_OPTIMIZATIONS setting for compilation_level works great on impact's game.min.js file after baking.
However, as you can see here:
Example Javascript:
function unusedFunction(note) { alert(note['text']); } function displayNoteTitle(note) { alert(note['title']); } var flowerNote = {}; flowerNote['title'] = "Flowers"; displayNoteTitle(flowerNote);
Compilation with SIMPLE_OPTIMIZATIONS shortens the code to this:
function unusedFunction(a){alert(a.text)}function displayNoteTitle(a){alert(a.title)}var flowerNote={};flowerNote.title="Flowers";displayNoteTitle(flowerNote);
Compilation with ADVANCED_OPTIMIZATIONS shortens the code even further to this:
var a={};a.title="Flowers";alert(a.title);
the ADVANCED_OPTIMIZATIONS flag would add a huge level of obfuscation which, for me, creates an enormous benefit in protecting the source code. Unfortunately, when I compile with ADVANCED_OPTIMIZATIONS I get an "ig is not defined" error when I run my game... *tear.
Has anyone successfully compiled against ADVANCED_OPTIMIZATIONS? If not, any chance the impact engine could be changed to support that flag?
here's the code surrounding the bug:
From Baked: (this works in chrome)
// lib/impact/image.js ig.baked=true; //line 369
From Closure Compiler with: SIMPLE_OPTIMIZATIONS (this works in chrome)
ig.baked=!0; // line 262
From Closure Compiler with ADVANCED_OPTIMIZATIONS (this does not work, gives error on line 258)
ig.j=g; //line 258, error is Uncaught ReferenceError: ig is not defined (anonymous function) ig.m("impact.image").l(function(){