The read-only didTimeout
property on the IdleDeadline
interface is a Boolean value which indicates whether or not the idle callback is being invoked because the timeout interval specified when Window.requestIdleCallback()
was called has expired.
If didTimeout
is true
, the IdleDeadline
object's timeRemaining()
method will return approximately 0.
Idle callbacks support the concept of a timeout in order to ensure that whatever task they're meant to perform actually happens, even if the user agent never has enough idle time available. Your callback will typically check the value of didTimeout
if it needs to perform an action even if the browser is too busy to grant you the time; you should react by performing the needed task or, ideally, a minimal amount of work that can be done to keep things moving along, then schedule a new callback to try again to get the rest of the work done.
var timedOut = IdleDeadline.didTimeout;
A Boolean which is true
if the callback is running due to the callback's timeout period elapsing or false
if the callback is running because the user agent is idle and is offering time to the callback.
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.
IdleDeadline
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/didTimeout