Contact emails
Spec
Summary
An API which allows posting of tasks which are schedule during periods when the browser is idle, and are passed a deadline, when called, which is calculated based on how long the browser expects to remain idle. This enables developers to perform background work on the main event loop, without impact latency-critical events such as animation and input response.
Motivation
Web pages often want to execute computation tasks on the browser's event loop which are not time-critical, but might take a significant portion of time to perform. Currently these background tasks are typically performed using setTimeout. The disadvantage of this approach is that the browser has no way of knowing whether a given setTimeout callback is time-critical or could be delayed until the browser is otherwise idle. In addition, the browser isn't able to provide the callback with any information about how long it can continue to execute without delaying time-critical operations and causing jank or other user-perceptible delays.
The requestIdleCallback API is intended to mitigate these issues by enabling developers to explicitly mark non-urgent background work as such, and to provide the callback with an estimation of how long the browser expects to remain idle.
The motivation of API came from our work on the Blink Scheduler, where a similar API is provided internally and is used by various components of Blink to schedule background work.
Compatibility Risk
Safari: No public signals
Web developers: Positive
There is
some discussion on the spec as to whether this API should be Promise based instead of callback based. We will not ship this API before this has been decided, but intend to implement support in Chrome for the callback implementation (behind a flag) to allow experimentation.
Developers will be able to detect whether this API is available with simple feature detection (checking if the requestIdleCallback function exists).
Ongoing technical constraints
None
Will this feature be supported on all six Blink platforms (Windows, Mac, Linux,
Chrome OS, Android, and Android WebView)?
Yes
OWP launch tracking bug
Link to entry on the Chromium Dashboard
Requesting approval to ship?
No