JS Compiler

Discussion and feedback on Construct 2

Post » Wed Feb 16, 2011 2:57 pm

Is the c2 runtime compiled by googles closure compiler? (it looks like it is, just asking out of curiosity!)

Is there any downside to not compiling it apart from obvious bandwidth and slight speed improvement? I only ask, because if a game throws a JS error, isn't it going to be really difficult to debug it? Is having it obfuscated important? would it be good if developer mode is on to non compile it?
Image Image
Scirra Founder
B
125
S
37
G
25
Posts: 3,945
Reputation: 44,922

Post » Wed Feb 16, 2011 3:11 pm

It's not compiled by closure. It's something you can do yourself easily by pasting c2runtime.js in to the Google closure compiler web service. However, it doesn't seem to survive 'advanced optimizations', only use 'simple optimizations' - working out why advanced kills it is something on my todo list.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,590

Post » Wed Feb 16, 2011 3:22 pm

Ah sorry, I looked at the ghost hunter one and it seems to be compiled so thought they all were.

In regards to advanced killing, let me know what you find out because I have scripts that don't survive it either.
Image Image
Scirra Founder
B
125
S
37
G
25
Posts: 3,945
Reputation: 44,922

Post » Wed Feb 16, 2011 3:34 pm

One thing that may help in advanced mode is putting all your compiled code in any anonymous function wrapper:

$(function() {

});

Change the last line to:

})();

if it needs to execute the code block as soon as it's loaded.

This stops conflicts with any other scripts apparently in the global scope which can cause issues. For example if the Jquery.min is in the global namespace there will be conflicts between minified variable names as the closure compiler declares things such as:

var s = true, x = null, v = false;

These might conflict with Jquery minified code.

You probably know all this but just incase it's the issue.
Image Image
Scirra Founder
B
125
S
37
G
25
Posts: 3,945
Reputation: 44,922


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 2 guests

cron