title: How to use WebAssembly (wasm) code in a Web Worker?
body: <p>Currently, a Web Worker is instantiated thus:</p>
  
  <pre><code>let worker = new Worker('worker.js');
  </code></pre>
  
  <p>The browser then fetches <code>worker.js</code> and it can start responding to messages.</p>
  
  <p>I'd like to implement my worker's functionality using WebAssembly. Ideally, I'd like to do something like this:</p>
  
  <pre><code>let worker = new Worker('worker.wasm');
  </code></pre>
  
  <p>But I'm pretty sure that's not possible. The most obvious alternative is to have <code>worker.js</code> fetch <code>worker.wasm</code> and compile and run it. But this means we fetch one script (<code>worker.js</code>) whose only job is to fetch and run another script (<code>worker.wasm</code>). This feels gross to me. And so my question: is there a cleaner way of using WebAssembly within a Web Worker, which won't introduce an extra fetch step?</p>