The IdleDeadline
interface is used as the data type of the input parameter to idle callbacks established by calling Window.requestIdleCallback()
. It offers a method, timeRemaining()
, which lets you determine how much longer the user agent estimates it will remain idle and a property, didTimeout
, which lets you determine if your callback is executing because its timeout duration expired.
To learn more about how request callbacks work, see Collaborative Scheduling of Background Tasks.
Properties
IdleDeadline.didTimeout
Read only- A Boolean whose value is
true
if the callback is being executed because the timeout specified when the idle callback was installed has expired.
Methods
IdleDeadline.timeRemaining()
- Returns a
DOMHighResTimeStamp
, which is a floating-point value providing an estimate of the number of milliseconds remaining in the current idle period. If the idle period is over, the value is 0. Your callback can call this repeatedly to see if there's enough time left to do more work before returning.
Example
See our complete example in the article Cooperative Scheduling of Background Tasks API.
Specifications
Specification | Status | Comment |
Cooperative Scheduling of Background Tasks | Proposed Recommendation |
Browser compatibility
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
IdleDeadline
|
Chrome
Full support 47 |
Edge
Full support 79 |
Firefox Full support 55 Full support 55 Full support 53 Disabled' From version 53: this feature is behind the |
IE
No support No |
Opera
Full support 34 |
Safari
No support No |
WebView Android
Full support 47 |
Chrome Android
Full support 47 |
Firefox Android Full support 55 Full support 55 Full support 53 Disabled' From version 53: this feature is behind the |
Opera Android
Full support 34 |
Safari iOS
No support No |
Samsung Internet Android
Full support 5.0 |
didTimeout
|
Chrome
Full support 47 |
Edge
Full support 79 |
Firefox Full support 55 Full support 55 Full support 53 Disabled' From version 53: this feature is behind the |
IE
No support No |
Opera
Full support 34 |
Safari
No support No |
WebView Android
Full support 47 |
Chrome Android
Full support 47 |
Firefox Android Full support 55 Full support 55 Full support 53 Disabled' From version 53: this feature is behind the |
Opera Android
Full support 34 |
Safari iOS
No support No |
Samsung Internet Android
Full support 5.0 |
timeRemaining
|
Chrome
Full support 47 |
Edge
Full support 79 |
Firefox Full support 55 Full support 55 Full support 53 Disabled' From version 53: this feature is behind the |
IE
No support No |
Opera
Full support 34 |
Safari
No support No |
WebView Android
Full support 47 |
Chrome Android
Full support 47 |
Firefox Android Full support 55 Full support 55 Full support 53 Disabled' From version 53: this feature is behind the |
Opera Android
Full support 34 |
Safari iOS
No support No |
Samsung Internet Android
Full support 5.0 |
Legend
- Full support
- Full support
- No support
- No support
- User must explicitly enable this feature.'
- User must explicitly enable this feature.
See also
- Cooperative Scheduling of Background Tasks API
Window.requestIdleCallback()
Window.cancelIdleCallback()
IdleDeadline by Mozilla Contributors is licensed under CC-BY-SA 2.5.