Window: requestIdleCallback() method - Web APIs | MDN
https://developer.mozilla.org/en-US/docs/Web/API/Window/requestIdleCallback • 180 KB fetched Open original page
Window: requestIdleCallback() method - Web APIs | MDN
*
Skip to main content
*
Skip to search
HTML
HTML: Markup language
HTML reference
*
Elements
*
Global attributes
*
Attributes
*
See all…
HTML guides
*
Responsive images
*
HTML cheatsheet
*
Date & time formats
*
See all…
Markup languages
*
SVG
*
MathML
*
XML
CSS
CSS: Styling language
CSS reference
*
Properties
*
Selectors
*
At-rules
*
Values
*
See all…
CSS guides
*
Box model
*
Animations
*
Flexbox
*
Colors
*
See all…
Layout cookbook
*
Column layouts
*
Centering an element
*
Card component
*
See all…
JavaScript JS
JavaScript: Scripting language
JS reference
*
Standard built-in objects
*
Expressions & operators
*
Statements & declarations
*
Functions
*
See all…
JS guides
*
Control flow & error handing
*
Loops and iteration
*
Working with objects
*
Using classes
*
See all…
Web APIs
Web APIs: Programming interfaces
Web API reference
*
File system API
*
Fetch API
*
Geolocation API
*
HTML DOM API
*
Push API
*
Service worker API
*
See all…
Web API guides
*
Using the Web animation API
*
Using the Fetch API
*
Working with the History API
*
Using the Web speech API
*
Using web workers
All
All web technology
Technologies
*
Accessibility
*
HTTP
*
URI
*
Web extensions
*
WebAssembly
*
WebDriver
*
See all…
Topics
*
Media
*
Performance
*
Privacy
*
Security
*
Progressive web apps
Learn
Learn web development
Frontend developer course
*
Getting started modules
*
Core modules
*
MDN Curriculum
*
Check out the video course from Scrimba, our partner
Learn HTML
*
Structuring content with HTML module
Learn CSS
*
CSS styling basics module
*
CSS layout module
Learn JavaScript
*
Dynamic scripting with JavaScript module
Tools
Discover our tools
*
Playground
*
HTTP Observatory
*
Border-image generator
*
Border-radius generator
*
Box-shadow generator
*
Color format converter
*
Color mixer
*
Shape generator
About
Get to know MDN better
*
About MDN
*
Advertise with us
*
Community
*
MDN on GitHub
Blog
Toggle sidebar
*
Web
*
Web APIs
*
Window
*
requestIdleCallback()
Theme
*
OS default
*
Light
*
Dark
English (US)
Remember language
Learn more
*
Deutsch
*
English (US)
*
Español
*
Français
*
日本語
*
한국어
*
Português (do Brasil)
*
Русский
*
中文 (简体)
Window: requestIdleCallback() method
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Want more browser support for this feature? Tell us why.
*
See full compatibility
*
Learn more
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 thread, 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.
In this article
*
Syntax
*
Examples
*
Specifications
*
Browser compatibility
*
See also
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
window.cancelIdleCallback() method.
Examples
See our complete example
in the article Cooperative Scheduling of Background Tasks API .
Specifications
Specification
requestIdleCallback()
# the-requestidlecallback-method
Browser compatibility
See also
* Window.cancelIdleCallback()
* IdleDeadline
* Window.setTimeout()
* Window.setInterval()
* Window.requestAnimationFrame()
Help improve MDN
Yes
No
Learn how to contribute
This page was last modified on Jun 23, 2025 by MDN contributors .
View this page on GitHub • Report a problem with this content
Clear filter input
* HTML DOM API
* Window
* Instance properties
* caches
* closed
* cookieStore
* crashReport
* credentialless
* crossOriginIsolated
* crypto
* customElements
* devicePixelRatio
* document
* documentPictureInPicture
* event
* external
* fence
* frameElement
* frames
* fullScreen
* history
* indexedDB
* innerHeight
* innerWidth
* isSecureContext
* launchQueue
* length
* localStorage
* location
* locationbar
* menubar
* mozInnerScreenX
* mozInnerScreenY
* name
* navigation
* navigator
* opener
* orientation
* origin
* originAgentCluster
* outerHeight
* outerWidth
* parent
* performance
* personalbar
* scheduler
* screen
* screenLeft
* screenTop
* screenX
* screenY
* scrollbars
* scrollMaxX
* scrollMaxY
* scrollX
* scrollY
* self
* sessionStorage
* sharedStorage
* speechSynthesis
* status
* statusbar
* toolbar
* top
* trustedTypes
* viewport
* visualViewport
* window
* Instance methods
* alert()
* atob()
* blur()
* btoa()
* cancelAnimationFrame()
* cancelIdleCallback()
* captureEvents()
* clearImmediate()
* clearInterval()
* clearTimeout()
* close()
* confirm()
* createImageBitmap()
* dump()
* fetch()
* fetchLater()
* find()
* focus()
* getComputedStyle()
* getDefaultComputedStyle()
* getScreenDetails()
* getSelection()
* matchMedia()
* moveBy()
* moveTo()
* open()
* postMessage()
* print()
* prompt()
* queryLocalFonts()
* queueMicrotask()
* releaseEvents()
* reportError()
* requestAnimationFrame()
* requestFileSystem()
* requestIdleCallback()
* requestResize()
* resizeBy()
* resizeTo()
* scroll()
* scrollBy()
* scrollByLines()
* scrollByPages()
* scrollTo()
* setImmediate()
* setInterval()
* setResizable()
* setTimeout()
* showDirectoryPicker()
* showOpenFilePicker()
* showSaveFilePicker()
* sizeToContent()
* stop()
* structuredClone()
* webkitConvertPointFromNodeToPage()
* webkitConvertPointFromPageToNode()
* Events
* afterprint
* appinstalled
* beforeinstallprompt
* beforeprint
* beforeunload
* blur
* devicemotion
* deviceorientation
* deviceorientationabsolute
* error
* focus
* gamepadconnected
* gamepaddisconnected
* hashchange
* languagechange
* load
* message
* messageerror
* offline
* online
* orientationchange
* pagehide
* pagereveal
* pageshow
* pageswap
* popstate
* rejectionhandled
* resize
* scrollsnapchange
* scrollsnapchanging
* storage
* unhandledrejection
* unload
* vrdisplayactivate
* vrdisplayconnect
* vrdisplaydeactivate
* vrdisplaydisconnect
* vrdisplaypresentchange
* Inheritance
* EventTarget
* Related pages for HTML DOM
* BeforeUnloadEvent
* DOMStringMap
* ErrorEvent
* HTMLAnchorElement
* HTMLAreaElement
* HTMLAudioElement
* HTMLBRElement
* HTMLBaseElement
* HTMLBodyElement
* HTMLButtonElement
* HTMLCanvasElement
* HTMLDListElement
* HTMLDataElement
* HTMLDataListElement
* HTMLDialogElement
* HTMLDivElement
* HTMLDocument
* HTMLElement
* HTMLEmbedElement
* HTMLFieldSetElement
* HTMLFormControlsCollection
* HTMLFormElement
* HTMLFrameSetElement
* HTMLGeolocationElement
* HTMLHRElement
* HTMLHeadElement
* HTMLHeadingElement
* HTMLHtmlElement
* HTMLIFrameElement
* HTMLImageElement
* HTMLInputElement
* HTMLLIElement
* HTMLLabelElement
* HTMLLegendElement
* HTMLLinkElement
* HTMLMapElement
* HTMLMediaElement
* HTMLMenuElement
* HTMLMetaElement
* HTMLMeterElement
* HTMLModElement
* HTMLOListElement
* HTMLObjectElement
* HTMLOptGroupElement
* HTMLOptionElement
* HTMLOptionsCollection
* HTMLOutputElement
* HTMLParagraphElement
* HTMLPictureElement
* HTMLPreElement
* HTMLProgressElement
* HTMLQuoteElement
* HTMLScriptElement
* HTMLSelectElement
* HTMLSourceElement
* HTMLSpanElement
* HTMLStyleElement
* HTMLTableCaptionElement
* HTMLTableCellElement
* HTMLTableColElement
* HTMLTableElement
* HTMLTableRowElement
* HTMLTableSectionElement
* HTMLTemplateElement
* HTMLTextAreaElement
* HTMLTimeElement
* HTMLTitleElement
* HTMLTrackElement
* HTMLUListElement
* HTMLUnknownElement
* HTMLVideoElement
* HashChangeEvent
* History
* ImageData
* Location
* MessageChannel
* MessageEvent
* MessagePort
* Navigator
* PageRevealEvent
* PageSwapEvent
* PageTransitionEvent
* Plugin
* PluginArray
* PromiseRejectionEvent
* RadioNodeList
* TimeRanges
* UserActivation
* ValidityState
* WorkletGlobalScope
* Guides
* Using microtasks in JavaScript with queueMicrotask()
* In depth: Microtasks and the JavaScript runtime environment
Your blueprint for a better internet.
*
*
*
*
*
MDN
*
About
*
Blog
*
Mozilla careers
*
Advertise with us
*
MDN Plus
*
Product help
Contribute
*
MDN Community
*
Community resources
*
Writing guidelines
*
MDN Discord
*
MDN on GitHub
Developers
*
Web technologies
*
Learn web development
*
Guides
*
Tutorials
*
Glossary
*
Hacks blog
*
Website Privacy Notice
*
Telemetry Settings
*
Legal
*
Community Participation Guidelines
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license .
Links found on this page
- Skip to main content [direct]
- HTML: Markup language [direct]
- Elements [direct]
- Global attributes [direct]
- Attributes [direct]
- See all… [direct]
- Responsive images [direct]
- HTML cheatsheet [direct]
- Date & time formats [direct]
- See all… [direct]
- SVG [direct]
- MathML [direct]
- XML [direct]
- CSS: Styling language [direct]
- Properties [direct]
- Selectors [direct]
- At-rules [direct]
- Values [direct]
- See all… [direct]
- Box model [direct]
- Animations [direct]
- Flexbox [direct]
- Colors [direct]
- See all… [direct]
- Column layouts [direct]
- Centering an element [direct]
- Card component [direct]
- See all… [direct]
- JavaScript: Scripting language [direct]
- Standard built-in objects [direct]
- Expressions & operators [direct]
- Statements & declarations [direct]
- Functions [direct]
- See all… [direct]
- Control flow & error handing [direct]
- Loops and iteration [direct]
- Working with objects [direct]
- Using classes [direct]
- See all… [direct]
- Web APIs: Programming interfaces [direct]
- File system API [direct]
- Fetch API [direct]
- Geolocation API [direct]
- HTML DOM API [direct]
- Push API [direct]
- Service worker API [direct]
- Using the Web animation API [direct]
- Using the Fetch API [direct]
- Working with the History API [direct]
- Using the Web speech API [direct]
- Using web workers [direct]
- All web technology [direct]
- Accessibility [direct]
- HTTP [direct]
- URI [direct]
- Web extensions [direct]
- WebAssembly [direct]
- WebDriver [direct]
- Media [direct]
- Performance [direct]
- Privacy [direct]
- Security [direct]
- Progressive web apps [direct]
- Learn web development [direct]
- Getting started modules [direct]
- Core modules [direct]
- MDN Curriculum [direct]
- Check out the video course from Scrimba, our partner [direct]
- Structuring content with HTML module [direct]
- CSS styling basics module [direct]
- CSS layout module [direct]
- Dynamic scripting with JavaScript module [direct]
- Playground [direct]
- HTTP Observatory [direct]
- Border-image generator [direct]
- Border-radius generator [direct]
- Box-shadow generator [direct]
- Color format converter [direct]
- Color mixer [direct]
- Shape generator [direct]
|
|