When to use web workers
My experience with Web Workers was terrible. It's not because of the Web Workers itself but there is no proper standard way to use modules inside of the worker.<p>Because it requires a separated .js file to instantiate, bundlers like webpack tend to introduce weird and non-standard way to work with [1].<p>It is usually fine when you use it your own project since you are going to stick with a bundler you choose anyway, but the worst things happens when you try to publish a JS library that uses a web worker internally. You cannot just publish the source because bundlers won't recognize require() and imports syntax in the web worker source code out of the box.<p>There is a ES standard:<p><pre><code>  new Worker("worker.js", { type: "module" }); 
</code></pre>
but no browsers implementations yet and some people aren't happy with this because it is not async [2].<p>[1]: <a href="https://github.com/webpack-contrib/worker-loader/blob/master/README.md#config" rel="nofollow">https://github.com/webpack-contrib/worker-loader/blob/master...</a><p>[2]: <a href="https://bugs.chromium.org/p/chromium/issues/detail?id=680046" rel="nofollow">https://bugs.chromium.org/p/chromium/issues/detail?id=680046</a>