title: Web worker importScripts DOMException script failed to load
body: <p>I'm trying to use <code>importScripts</code></p>
  
  <pre><code>self.addEventListener('fetch', event =&gt; {
    ...
    self.importScripts('idb.js');
    ...
  }
  </code></pre>
  
  <p>to load a library for a service worker for a PWA but keep getting</p>
  
  <pre><code>DOMException: Failed to execute 'importScripts' on 'WorkerGlobalScope': 
      The script at 'http://localhost:3000/idb.js' failed to load.
  </code></pre>
  
  <p>The script file is there, content type is correct, <code>application/javascript</code>, and I've tried it with <code>text/javascript</code> too. My developer tools network tab shows the request starting and then failing really quickly, not getting a chance to hit the server. The status code is <code>(failed) net::ERR_CONNECTION_REFUSED</code> when over http and <code>(failed) net::ERR_FAILED</code> over https. Any help appreciated</p>