title: Loading external Javascript Sequentially
body: <p>I am working on a javascript that sequentially loads a list of other external javascript.</p>
  
  <p>The code I have so far:</p>
  
  <pre><code>function loadJavascript(url){
      var js = document.createElement("script");
  
      js.setAttribute("type", "text/javascript");
      js.setAttribute("src", url);
  
      if(typeof js!="undefined"){
          document.getElementsByTagName("head")[0].appendChild(js)
      }
  }
  
  loadJavascript("Jquery.js");
  loadJavascript("second.js");
  loadJavascript("third.js");
  </code></pre>
  
  <p>The problem I ran into is that sometimes the other js files loads before the Jquery file completes its loading. This gives me some errors.</p>
  
  <p>Is it possible to make it so that the next JS file is only initiated when the previous file is finished loading.</p>
  
  <p>Thanks in advance</p>