title: Why JS scripts are run in the wrong order
body: <p>In my web app, you can open an iframe which load a report (similar to an excel spreadsheet). The reports open fine for a while (15-20 times). At some point, I will start always getting JS errors about kendo being undefined and I occasionally  get "Insufficient memory" errors in IE console.</p>
  
  <p>As you can see in my HTML , the kendo.all.min.js file comes before the kendo.sage.custom.min.js file.</p>
  
  <pre><code>&lt;script type="text/javascript" src="/Scripts/kendo/web/kendo.all.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="/Scripts/kendo/kendo.sage.custom.min.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>When all goes well, fiddler shows<a href="https://i.stack.imgur.com/CNpRS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CNpRS.png" alt="enter image description here"></a></p>
  
  <p>But when i start getting errors, I can see the following : <a href="https://i.stack.imgur.com/orvdr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/orvdr.png" alt="scripts wrong order"></a></p>
  
  <p>So for some reason, after using my app for a while, the scripts will load in the wrong order.</p>
  
  <p>So I added console.log("all") and console.log("sage")at the top of each script. When working normally, I can see in order "all" and then "sage", but when I start getting the kendo undefined error, all i see is the "sage" log, never the "all".</p>
  
  <p>We are using ASP.NET MVC and the scripts are in our layout file in the head section.</p>
  
  <p>What could cause the scripts to be run in the wrong order ?</p>