How to handle CPU-intensive tasks
Web workers make the application fast by running CPU-intensive tasks on a different thread other than the main thread.
Last updated
Was this helpful?
Web workers make the application fast by running CPU-intensive tasks on a different thread other than the main thread.
Last updated
Was this helpful?
Sorting, search, graph traversal, matrix multiply are all CPU operations, a process is CPU-intensive
or not it depends on how much and how frequent are their execution.
are a simple means for web content to run scripts in background threads. The worker thread can perform tasks without interfering with the user interface.
- a webpack loader that moves a module and its dependencies into a Web Worker, automatically reflecting exported functions as asynchronous proxies.
workerized-expensive.js
expensive.js is our function that may slow down an application.
If you're using Babel in your build, make sure you . Otherwise, workerize-loader won't be able to retrieve the list of exported function from your worker script
Because working with web workers is asynchronous, you'll probably want to use the useAsync