Implement mw.requestIdleCallback for deferred background tasks
authorTimo Tijhof <krinklemail@gmail.com>
Wed, 21 Oct 2015 01:52:52 +0000 (02:52 +0100)
committerOri.livneh <ori@wikimedia.org>
Tue, 10 Nov 2015 18:48:25 +0000 (18:48 +0000)
commit2905943e54dfc9067dbb332b054e32eef72088f2
tree456696f52429e5c43d9fa94eb1617ed1056e9e7f
parent5cb16e7711354fb3a39913d5a38d55367751d81b
Implement mw.requestIdleCallback for deferred background tasks

We often use the idiom "window.onload" or "$(window).on('load')".
Since code loads asynchronous, this is problematic because the event won't
always be observed as it may fire before the event handler is attached.

Most tasks also don't really want to wait until the page is loaded (in which
case it would run immediately if the page is already loaded). Rather their intent
is just to defer it to a later point in time – to avoid disrupting user events.

Bug: T111456
Change-Id: Ieba0440c6d83086762c777dfbbc167f1c314a751
resources/Resources.php
resources/src/mediawiki/mediawiki.requestIdleCallback.js [new file with mode: 0644]
tests/qunit/QUnitTestResources.php
tests/qunit/suites/resources/mediawiki/mediawiki.requestIdleCallback.test.js [new file with mode: 0644]