Safely schedules a callback to be executed when the browser is idle. Falls back to setTimeout if requestIdleCallback is not available.
The function to execute during idle time
Optional
Optional configuration (timeout in ms)
A handle that can be passed to cancelScheduledCallback
const handle = scheduleIdleCallback(() => { console.log('Running during idle time');});// Later, if needed:cancelScheduledCallback(handle); Copy
const handle = scheduleIdleCallback(() => { console.log('Running during idle time');});// Later, if needed:cancelScheduledCallback(handle);
Safely schedules a callback to be executed when the browser is idle. Falls back to setTimeout if requestIdleCallback is not available.