title: Access function present in dynamically added javascript file
body: <p>I'm adding some javascript files. Then I need to use functions present in them. In firebug's <code>Scripts</code> tab, I can see that the scripts are added. Function <code>LoadScript1Function</code> is present in one script and <code>LoadScript2Function</code> in other. 
  But the error i'm getting is:</p>
  
  <pre><code>`ReferenceError: LoadScript1Function is not defined`
  </code></pre>
  
  <p>Here's my code:</p>
  
  <pre><code>function LoadScripts(){
      try{
          var allScripts = document.getElementsByTagName('script');
          for (var x = 0; x &lt; jsPaths.length; x++) {
              if($.inArray(jsPaths[x], allScripts) == -1){
                  loadScript(jsPaths[x], null);
              } 
          }
  
          async(LoadScript1Function, function(){ ; });
          async(LoadScript2Function, function(){ ; });
      }
      catch(e){
          console.log(e);
      }
  }
  
  // Load script
  function loadScript(url, callback){
      var script = document.createElement("script");
      script.type = "text/javascript";
  
      if (script.readyState){  //IE
          script.onreadystatechange = function(){
              if (script.readyState == "loaded" ||
                      script.readyState == "complete"){
                  script.onreadystatechange = null;
                  callback();
              }
          };
      } else {  //Others
          script.onload = function(){
              callback();
          };
      }
  
      script.src = url;
      document.getElementsByTagName("head")[0].appendChild(script);
  }
  
  // Async call
  function async(fn, callback) {
      setTimeout(function() {
          fn();
          callback();
      }, 0);
  }
  </code></pre>
  
  <p>Tried following as per <code>adeneo</code>'s suggestion. But not working.</p>
  
  <pre><code>loadScript(jsPaths[x], function(){ 
       if(jsPaths[x].indexOf('Script1') != -1){ // script name check in the path
           LoadScript1Function();
       }
  });
  </code></pre>