Simple polyfill and d.ts for requestIdleCallback.
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.
npm i requestidlecallback-polyfill
yarn add requestidlecallback-polyfill