4 ms·
On a related note, if you are building a UI, an even better solution for computationally intensive work is to offload it onto a separate process instead of just
by slaymaker1907 5y ago
On a related note, if you are building a UI, an even better solution for computationally intensive work is to offload it onto a separate process instead of just a separate thread. This ensures that the UI thread is not blocked as often due to GC. Obviously this isn't really possible in JS (outside of Electron), but this can be a good idea in languages like Java.
- croshan 5y agoI think this is possible to do with JS + WASM/Service workers? And even with many background threads, in WASM: https://developers.google.com/web/updates/2018/10/wasm-threads https://developers.google.com/web/updates/2018/10/wasm-threa...
- esprehn 5y agoThere's overhead to a process that doesn't exist with threads. You can definitely split your work across threads in JS using Workers, ServiceWorkers and the main thread. Most apps don't take advantage of this very well though. Using a separate thread gets you the same GC benefits. There have been some attempts to make it easier to use threads on the web like the excellent Comlink library: https://github.com/GoogleChromeLabs/comlink https://github.com/GoogleChromeLabs/comlink
- pjmlp 5y agoIt has been possible for quite a while with background workers.