Currently, a Web Worker is instantiated thus:
let worker = new Worker('worker.js');
The browser then fetches worker.js and it can start responding to messages.
I'd like to implement my worker's functionality using WebAssembly. Ideally, I'd like to do something like this:
let worker = new Worker('worker.wasm');
But I'm pretty sure that's not possible. The most obvious alternative is to have worker.js fetch worker.wasm and compile and run it. But this means we fetch one script (worker.js) whose only job is to fetch and run another script (worker.wasm). 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?
Workerin the first instance ifWorkeris not intended to be used? No actual problem statement exists at Question.