How to init a global variable if it is not present?
<p>I load the same script in my page many times. I have some trouble on decide which is loaded first/after in my website, due to the async/load functions.</p>

<p>So, I'd like to put a global variable that count, when the script is loaded, the order of them.</p>

<p>So myScript.js will start with :</p>

<pre><code>(function () {
    var privateNumberScriptLoaded;

    if (numberScriptLoaded === undefined) {
        numberScriptLoaded = 0;
    }
    else {
        numberScriptLoaded = numberScriptLoaded + 1;
    }

    privateNumberScriptLoaded = numberScriptLoaded;
    console.log(privateNumberScriptLoaded);
})();
</code></pre>

<p>but when I load it with :</p>

<pre><code>&lt;script src="http://www.mywebsite.com/widget/myScript.js?type=normal" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="http://www.mywebsite.com/widget/myScript.js?type=rotation" type="text/javascript"&gt;&lt;/script&gt;
</code></pre>

<p>I get (for two times) <code>numberScriptLoaded is not defined</code>.</p>

<p>How can I resolve this trouble? In fact I'll "create" a global variable in my website if it doesnt exist. Than increment it and store in a "private" variable for each script, so I can save the order of the execution for each script.</p>
