if you postpone execution of some calculations that does not solves the problem, just delays the inevitable. Eg. doing JSON.parse(); immediately after the async action can instantly block the execution stack. Not to mention any other further data processing. In many cases such computation should be done from within the Worker.
scope (Window obj) and it can be instantiated with new Worker(); Many Workers per tab. Is VERY well supported! serviceWorker needs to be registered via navigator.serviceWorker.register(); One serviceWorker per origin (domain). No XMLHttpRequest, only fetch! It can be used as a proxy with full caching support. PWA depend on it heavily for providing the “offline” experience to the end user. It have limited support.
= new Worker('webworker.js'); main context Here is piece of info… worker.postMessage({ ...data }); webworker I am listening… onmessage = event => { return process(event.data); } main context I will be waiting for the response… worker.onmessage = event => { console.log(event.data); }
heavy calculations on the FE will endanger the UX, even if executed in the different thread. Since devices that run our JS apps are limited in resources. Multi-threading is not about lifting heavy weight. It’s about not blocking your main stack.