c2runtime pollutes global namespace

Bugs will be moved here once resolved.

Post » Wed Mar 09, 2016 5:10 pm

Problem Description
c2runtime.js creates a lot of global variables.

For example: the first line of c2runtime starts with:
Code: Select all
'use strict';var aa,ba,ca,ea,y,fa,ga,ha,B,ja,ka,ma,na,oa,pa,C,qa,ra,N,ua,xa,ya,Aa,R,T,Ba,Ca,Da,Ea,U,Fa,Ga,V,Ha,Ia,Ja,Ka,La,Ma,Na,Oa,Pa,Qa,Ra,Sa,Ta,Ua,Va,Wa,Xa,Ya,Za,ab,bb,cb,db,eb,fb,gb,hb,ib,jb,kb,lb,mb,nb,ob,pb,qb,rb,sb,tb,ub,vb,wb,xb,yb,zb,Ab,Bb,Cb,Db,Eb,Fb,Gb,Hb,Ib,Jb,Kb,Lb,Mb,Nb,Ob,Pb,Qb,Rb,Sb,X,Tb,Ub={}

This is not a problem per se, but because these var names are minified we cannot use third party libraries safely. In our case some of these vars were overlapping with google tag manager code. (I spent the whole day locating the problem, never thought construct export would be this dirty ;) ).

I know it's more of a "best practice" thing than a bug, but it will remain a critical issue in some cases.

Attach a Capx

Description of Capx

Steps to Reproduce Bug
  • Step 1: make construct project
  • Step 2: export construct project

Observed Result
c2runtime pollutes global namespace

Expected Result
c2runtime should not pollute global namespace

And how to fix:
Code: Select all
at the beginning and
Code: Select all
at the end of the script file. Magic

(This is my temp fix at least. If there is another way to fix this, so I don't have to fiddle with every export, I'll be glad to hear it.)

Affected Browsers
  • Chrome: YES
  • FireFox: YES
  • Internet Explorer: YES

Operating System and Service Pack
windows 8

Construct 2 Version ID

PS: thanks in advance :)
Posts: 3
Reputation: 209

Post » Tue Mar 22, 2016 3:19 pm

Closing as not a bug, that is the output of Google Closure Compiler when you enable minification. This does make it difficult to integrate other libraries, but we already recommend doing that with our Javascript SDK anyway, which makes changes pre-minification (and so Closure Compiler will know to avoid name collisions).
Scirra Founder
Posts: 24,931
Reputation: 198,725

Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 8 guests