3 ms·
It's not about the computer being idle. It's about waiting for the main thread to be unblocked before doing stuff you would want to do anyway, but now you can s
by Kiro 4y ago
It's not about the computer being idle. It's about waiting for the main thread to be unblocked before doing stuff you would want to do anyway, but now you can schedule it for later to give priority to more urgent tasks. A very common optimization technique in all sorts of software and I don't see why it wouldn't be valid for a web application. Go read https://developer.mozilla.org/en-US/docs/Web/API/Background_Tasks_API https://developer.mozilla.org/en-US/docs/Web/API/Background_... for a better explanation.
- remram 4y agoYou still haven't answered the question. Your link has no example of use cases, though it has warnings about what not to do.
- collaborative 4y agoCan't reply above. So it's "low-priority" async?
- Kiro 4y agoExample: In a map application you give priority to rendering the visible map tiles while deferring preloading the surrounding non-visible tiles until the CPU is free. So basically it only renders tiles outside the viewport in a cache if the CPU is not already busy rendering what you're currently looking at. Any sort of thing that is not urgent and high priority, and where it's no big deal if it's not executed immediately will benefit from being run in requestIdleCallback.