title: What regulates whether a browser will or will not load JavaScript sources for a local HTML file?
body: <p>This is a <a href="https://webpack.js.org/" rel="nofollow noreferrer">Webpack</a>-generated index.html for an <a href="https://aurelia.io/" rel="nofollow noreferrer">Aurelia</a> page:</p>
  <pre><code>&lt;!doctype html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta charset=&quot;utf-8&quot;&gt;
      &lt;link href=&quot;assets/favicon_16x16.png&quot; rel=&quot;icon&quot; sizes=&quot;16x16&quot; type=&quot;image/png&quot;&gt;
      &lt;title&gt;Report NG&lt;/title&gt;
      &lt;meta content=&quot;width=device-width,initial-scale=1&quot; name=&quot;viewport&quot;&gt;
      &lt;base href=&quot;&quot;&gt;
      &lt;script defer=&quot;defer&quot; src=&quot;runtime~app.ff7b16a6e070e53c8cd6.bundle.js&quot;&gt;&lt;/script&gt;
      &lt;script defer=&quot;defer&quot; src=&quot;927.e593586868873e353304.bundle.js&quot;&gt;&lt;/script&gt;
      &lt;script defer=&quot;defer&quot; src=&quot;983.8ddf552f0b4036561207.bundle.js&quot;&gt;&lt;/script&gt;
      &lt;script defer=&quot;defer&quot; src=&quot;417.0b982aa38fb2bce8d391.bundle.js&quot;&gt;&lt;/script&gt;
      &lt;script defer=&quot;defer&quot; src=&quot;212.46a12b9521ba6317f9b1.bundle.js&quot;&gt;&lt;/script&gt;
      &lt;script defer=&quot;defer&quot; src=&quot;app.42fbcddde62f263b1a4c.bundle.js&quot;&gt;&lt;/script&gt;
      &lt;link href=&quot;css/983.5102c6f24c10258b523a.chunk.css&quot; rel=&quot;stylesheet&quot;&gt;
      &lt;link href=&quot;css/417.78495966cfa48fb59a61.chunk.css&quot; rel=&quot;stylesheet&quot;&gt;
      &lt;link href=&quot;css/app.327e04e57f327850ab7d.chunk.css&quot; rel=&quot;stylesheet&quot;&gt;
  &lt;/head&gt;
  &lt;body aurelia-app=&quot;main&quot;&gt;&lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>If I open this index.html on my local machine, the scripts (in the same folder) will be loaded and run.</p>
  <p>This is a hand-written MVE index.html :</p>
  <pre><code>&lt;!doctype html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta charset=&quot;utf-8&quot;&gt;
      &lt;title&gt;MVE_localDataDependency&lt;/title&gt;
  
      &lt;script defer=&quot;defer&quot; src=&quot;data.js&quot; type=&quot;module&quot;&gt;&lt;/script&gt;
      &lt;script&gt;
          import {read} from &quot;./data&quot;
          read()
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;&lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>It will not load <code>data.js</code> (in the same folder) but rather abort with a CORS error. <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors/CORSRequestNotHttp#loading_a_local_file" rel="nofollow noreferrer">This is the expected behaviour.</a></p>
  <p>... Why are the scripts loaded in the generated page?</p>
  <p>Notes:</p>
  <ul>
  <li>Browsers may have a global setting to allow loading local scripts, <a href="https://stackoverflow.com/questions/58067499/runing-javascript-in-local-html-files-in-firefox">e.g. in Firefox</a>. This does not explain, why the same browser, in two simultaneously open tabs, loads script files for one HTML file but not for the other one.</li>
  <li>I double checked that both <code>index.html</code> files appear in the Browser tab as &quot;file:///&quot;, so not a case of &quot;your IDE accidentally auto-served this&quot;.</li>
  <li>Behaviour is identical in both Chrome and Firefox.</li>
  </ul>