• Safely schedules a callback to be executed when the browser is idle. Falls back to setTimeout if requestIdleCallback is not available.

    Parameters

    • callback: IdleRequestCallback

      The function to execute during idle time

    • Optional options: IdleRequestOptions

      Optional configuration (timeout in ms)

    Returns IdleCallbackHandle

    A handle that can be passed to cancelScheduledCallback

    Example

    const handle = scheduleIdleCallback(() => {
    console.log('Running during idle time');
    });

    // Later, if needed:
    cancelScheduledCallback(handle);

Generated using TypeDoc