How to ensure my self executing block is executed and ready for use in javascript
<p>I have 2 script files</p>

<p>File1.js</p>

<pre><code>var module = com.utils.createNamespace('com.PDP.OrderMySampleTemplate');
(function(OrderMySampleTemplate) {
    .....
})(module);
</code></pre>

<p>File2.js</p>

<pre><code>var module = com.utils.createNamespace('com.PDP.OrderMySample');
(function($,m,OrderMySample,OrderMySampleTemplate) {
    ......
})(jquery,mustache,module,com.PDP.OrderMySampleTemplate);
</code></pre>

<p>and in my JSP i make a call to the init method defined in File2</p>

<pre><code>&lt;script&gt;
    $(document).ready( function() { com.PDP.OrderMySample.init(); } );
&lt;/script&gt;
</code></pre>

<p>I get a JS error saying the variables com.PDP.OrderMySample is not defined.
Both file1,file2 and the JSP which invokes them are downloaded as Ajax response
My question here is how can i ensure that all my JS files are downloaded and the self executing blocks are executed so that I can make use of those variables to invoke the function inside it</p>
