DEV Community

Discussion on: Javascript long-running tasks - Use CPU's idle periods

Collapse
 
patriziobruno profile image
Patrizio Bruno

Very interesting approach. I do prefer webworkers, but they can't access the DOM. This is a good alternative, when from your worker function you need to call a library that reads/writes the DOM.

Collapse
 
canastro profile image
Ricardo Canastro • Edited

Indeed webworkers are good solution for most of use-cases and I have used them way more often then this approach.

I haven't yet benchmark it yet (I hope I have time to do it), but passing data to the webworker and back adds some overhead. Depending on the type and amount of data that overhead might take a toll in time to execute and memory usage.