• Web APIs
  • Window
  • Instance properties
    1. credentialless Experimental
    2. devicePixelRatio
    3. documentPictureInPicture Experimental
    4. event Deprecated
    5. external Deprecated
    6. fence Experimental
    7. fullScreen Non-standard
    8. innerWidth
    9. launchQueue Experimental
    10. locationbar
    11. mozInnerScreenX Non-standard
    12. mozInnerScreenY Non-standard
    13. navigation Experimental
    14. orientation Deprecated
    15. originAgentCluster Experimental
    16. performance
    17. screenLeft
    18. scrollbars
    19. scrollMaxX Non-standard
    20. scrollMaxY Non-standard
    21. sessionStorage
    22. sharedStorage Experimental
    23. status Deprecated
    24. trustedTypes
    25. atob()
    26. back() Non-standard Deprecated
    27. blur() Deprecated
    28. captureEvents() Deprecated
    29. clearImmediate() Non-standard Deprecated
    30. confirm()
    31. dump() Non-standard
    32. find() Non-standard
    33. forward() Non-standard Deprecated
    34. getDefaultComputedStyle() Non-standard
    35. getScreenDetails() Experimental
    36. moveTo()
    37. prompt()
    38. queryLocalFonts() Experimental
    39. releaseEvents() Deprecated
    40. requestFileSystem() Non-standard Deprecated
    41. scroll()
    42. scrollByLines() Non-standard
    43. scrollByPages() Non-standard
    44. setImmediate() Non-standard Deprecated
    45. setResizable() Non-standard Deprecated
    46. showDirectoryPicker() Experimental
    47. showModalDialog() Non-standard Deprecated
    48. showOpenFilePicker() Experimental
    49. showSaveFilePicker() Experimental
    50. sizeToContent() Non-standard
    51. webkitConvertPointFromNodeToPage() Non-standard Deprecated
    52. webkitConvertPointFromPageToNode() Non-standard Deprecated
  • Events
    1. beforeprint
    2. cut
    3. error
    4. hashchange
    5. messageerror
    6. orientationchange Deprecated
    7. pageswap
    8. resize
    9. scrollsnapchange Experimental
    10. scrollsnapchanging Experimental
    11. unload Deprecated
    12. vrdisplayactivate Non-standard Deprecated
    13. vrdisplayconnect Non-standard Deprecated
    14. vrdisplaydeactivate Non-standard Deprecated
    15. vrdisplaydisconnect Non-standard Deprecated
    16. vrdisplaypresentchange Non-standard Deprecated
  • Inheritance
    1. ErrorEvent
    2. HTMLBRElement
    3. HTMLCanvasElement
    4. HTMLDialogElement
    5. HTMLEmbedElement
    6. HTMLFrameSetElement Deprecated
    7. HTMLHtmlElement
    8. HTMLLIElement
    9. HTMLMapElement
    10. HTMLMeterElement
    11. HTMLOptGroupElement
    12. HTMLParagraphElement
    13. HTMLQuoteElement
    14. HTMLSpanElement
    15. HTMLTableColElement
    16. HTMLTemplateElement
    17. HTMLTrackElement
    18. HashChangeEvent
    19. MessageChannel
    20. PageRevealEvent
    21. Plugin Deprecated
    22. PluginArray Deprecated
    23. ValidityState
    24. Learn more
    25. See full compatibility
  • The window.requestIdleCallback() method queues a function to be called during a browser's idle periods. This enables developers to perform background and low priority work on the main event loop, without impacting latency-critical events such as animation and input response. Functions are generally called in first-in-first-out order; however, callbacks which have a timeout specified may be called out-of-order if necessary in order to run them before the timeout elapses.

    You can call requestIdleCallback() within an idle callback function to schedule another callback to take place no sooner than the next pass through the event loop.

    Note: A timeout option is strongly recommended for required work, as otherwise it's possible multiple seconds will elapse before the callback is fired.

    Syntax

    js
    requestIdleCallback(callback)
    requestIdleCallback(callback, options)
    

    Parameters

    callback

    A reference to a function that should be called in the near future, when the event loop is idle. The callback function is passed an IdleDeadline object describing the amount of time available and whether or not the callback has been run because the timeout period expired.

    options Optional

    Contains optional configuration parameters. Currently only one property is defined:

    timeout

    If the number of milliseconds represented by this parameter has elapsed and the callback has not already been called, then a task to execute the callback is queued in the event loop (even if doing so risks causing a negative performance impact). timeout must be a positive value or it is ignored.

    Return value

    An ID which can be used to cancel the callback by passing it into the complete example in the article Cooperative Scheduling of Background Tasks API.

    Specifications

    Specification
    requestIdleCallback()
    # the-requestidlecallback-method

    Browser compatibility

    BCD tables only load in the browser

    See also