title: How are JavaScript files loaded and executed?
body: <p>I don't often see talk or research on JavaScript file loading/executing order. I'm interested in sites explaining how JavaScript is being handled. In particular, if I have</p>
  
  <pre><code>&lt;script src="a.js"&gt;&lt;/script&gt;
  &lt;script src="b.js"&gt;&lt;/script&gt;
  &lt;script src="c.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>I presume a.js is downloaded first, then b.js and finally c.js or are they being downloaded concurrently? What about execution? Are scripts in the header preferred over ones in the body?</p>
  
  <p>The main reason why I'm so interested in this topic is because I'm writing a JavaScript software that uses dynamic loading of these scripts and sometimes I get errors like x is undefined (it hasn't been loaded before other scripts), but usually those errors won't occur. I don't understand why.</p>