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.
IdleDeadline.didTimeout
Read only
true
if the callback is being executed because the timeout specified when the idle callback was installed has expired.IdleDeadline.timeRemaining()
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.See our complete example in the article Cooperative Scheduling of Background Tasks API.
Specification | Status | Comment |
---|---|---|
Cooperative Scheduling of Background Tasks | Proposed Recommendation |
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|---|
Basic support | 47 | No support | 53 (53)[1] | No support | 34 | No support |
Feature | Android | Chrome | Firefox Mobile (Gecko) | Firefox OS | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|
Basic support | 53 | 55 | 53.0 (53)[1] | ? | No support | 37 | No support |
[1] Idle callback support was added in Firefox 53, but was disabled by default. To enable it, set the preference dom.requestIdleCallback.enabled
to true
. Idle callbacks are enabled by default starting in Firefox 55.
Window.requestIdleCallback()
Window.cancelIdleCallback()
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/IdleDeadline