c2runtime pollutes global namespace

0 favourites
  • 2 posts
From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • Problem Description

    c2runtime.js creates a lot of global variables.

    For example: the first line of c2runtime starts with:

    '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={}[/code:l7xjvx7p]
    
    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.
    
    [b]Attach a Capx[/b]
    N/A
        
    [b]Description of Capx[/b]
    N/A
    
    [b]Steps to Reproduce Bug[/b]
    [ul]
        [li] Step 1: make construct project
        [/li][li] Step 2: export construct project[/li][/ul]
        
    [b]Observed Result[/b]
    c2runtime pollutes global namespace
        
    [b]Expected Result[/b]
    c2runtime should not pollute global namespace
    
    And how to fix:
    Add [code:l7xjvx7p](function(){[/code:l7xjvx7p] at the beginning and [code:l7xjvx7p]})();[/code:l7xjvx7p] at the end of the script file. [i]Magic[/i]
    
    (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.)
    
    [b]Affected Browsers[/b]
    [ul]
        [li] Chrome: YES
        [/li][li] FireFox: YES
        [/li][li] Internet Explorer: YES[/li][/ul]
        
    [b]Operating System and Service Pack[/b]
    windows 8
        
    [b]Construct 2 Version ID[/b]
    r221
    
    [b]PS:[/b] thanks in advance
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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).

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)