3 ms·
This is a good approach for the times you can't use web workers. It's not just old browsers either. You can't draw to the canvas with a web worker. Depending o
by lancefisher 11y ago
This is a good approach for the times you can't use web workers. It's not just old browsers either. You can't draw to the canvas with a web worker.
Depending on what you're doing, you may want to yield after x operations rather than on every recursive invocation like the example shown. There is a performance cost to using setImmediate.
- yoklov 11y agoIt's massively unfortunate that a tradeoff like this has to be made (speed vs responsiveness). But FWIW, you can do canvas pixel operations with a web worker, which you then blit to the canvas, which is acceptable in some cases.