Skip to content

Instantly share code, notes, and snippets.

@pazguille
Created October 2, 2022 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pazguille/dfd9e692003359ae846ba88d4995a8de to your computer and use it in GitHub Desktop.
Save pazguille/dfd9e692003359ae846ba88d4995a8de to your computer and use it in GitHub Desktop.
requestidlecallback polyfill
window.requestIdleCallback = window.requestIdleCallback || function (cb) {
var start = Date.now();
return setTimeout(function () {
cb({
didTimeout: false,
timeRemaining: function () {
return Math.max(0, 50 - (Date.now() - start));
}
});
}, 1);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment