2 * An interface for scheduling background tasks.
4 * Loosely based on https://w3c.github.io/requestidlecallback/
9 mw
.requestIdleCallbackInternal = function ( callback
) {
10 setTimeout( function () {
14 timeRemaining: function () {
15 return Math
.max( 0, maxBusy
- ( mw
.now() - start
) );
22 * Schedule a deferred task to run in the background.
25 * @param {Function} callback
27 mw
.requestIdleCallback
= mw
.requestIdleCallbackInternal
;
29 // XXX: Polyfill disabled due to https://bugs.chromium.org/p/chromium/issues/detail?id=647870
30 mw.requestIdleCallback = window.requestIdleCallback
31 // Bind because it throws TypeError if context is not window
32 ? window.requestIdleCallback.bind( window )
33 : mw.requestIdleCallbackInternal;