title: jQuery script execution order in html injection
body: <p>Consider the following JS code:</p>
  
  <pre><code>var html = '&lt;script&gt;$("body").append("a");&lt;/script&gt;'
           + '&lt;script src="script.js"&gt;&lt;/script&gt;'
           + '&lt;script&gt;$("body").append("c");&lt;/script&gt;';
  
  $("body").append(html);
  </code></pre>
  
  <p>And assume that script.js contains the following:</p>
  
  <pre><code>$("body").append("b");
  </code></pre>
  
  <p>It seems that, indeed, "a", "b" and "c" are appended to body (<strong>in this order</strong>). And, obviously, "c" is appended to body only after <code>script.js</code> has finished loading (so, for example, if it takes 5 seconds for <code>script.js</code> to finish loading "c" will be appended to body only after 5 seconds).</p>
  
  <p>My question is the following: can we rely on this behavior in jQuery? Is it deterministic or we may encounter unpredictable situations?</p>
  
  <p>This would be useful in terms of dynamically loading scripts that make use of .js files that were not loaded yet. You can assume that script.js actually contains <code>function f(){}</code> and the third line would have been <code>&lt;script&gt;f()&lt;/script&gt;</code>. If you will always get the same order for the scripts loading/execution then there will be no issues, otherwise you may experience <code>f is not defined</code> exception (if the  tag is executed before loading the script.js file).</p>