From: Bartosz DziewoƄski Date: Sat, 15 Feb 2014 16:17:08 +0000 (+0100) Subject: Preload mediawiki.notification when we know we're going to need it soon X-Git-Tag: 1.31.0-rc.0~16879 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=f51b6015d84a9d67caa6b4a24b8420364ee49843;p=lhc%2Fweb%2Fwiklou.git Preload mediawiki.notification when we know we're going to need it soon The mediawiki.notification module is normally lazy-loaded when mw.notify() is called; however, this results in often-noticeable delay between when the action we're notifying about is complete and when the actual notification appears. Let's explicitly mw.loader.load() the module in event handlers which are going to later asynchronously fire a notification. I could only find two such situations in core: in mediawiki.page.patrol.ajax and mediawiki.page.watch.ajax. Bug: 53990 Change-Id: I9d20af3a2f261cd93d5d5fd2b81cccae79697481 --- diff --git a/resources/mediawiki.page/mediawiki.page.patrol.ajax.js b/resources/mediawiki.page/mediawiki.page.patrol.ajax.js index 75908eee32..5fb14dd733 100644 --- a/resources/mediawiki.page/mediawiki.page.patrol.ajax.js +++ b/resources/mediawiki.page/mediawiki.page.patrol.ajax.js @@ -16,6 +16,9 @@ $patrolLinks.on( 'click', function ( e ) { var $spinner, href, rcid, apiRequest; + // Start preloading the notification module (normally loaded by mw.notify()) + mw.loader.load( ['mediawiki.notification'], null, true ); + // Hide the link and create a spinner to show it inside the brackets. $spinner = $.createSpinner( { size: 'small', diff --git a/resources/mediawiki.page/mediawiki.page.watch.ajax.js b/resources/mediawiki.page/mediawiki.page.watch.ajax.js index 998a8c2a6b..948940370a 100644 --- a/resources/mediawiki.page/mediawiki.page.watch.ajax.js +++ b/resources/mediawiki.page/mediawiki.page.watch.ajax.js @@ -111,6 +111,9 @@ $links.click( function ( e ) { var action, api, $link; + // Start preloading the notification module (normally loaded by mw.notify()) + mw.loader.load( ['mediawiki.notification'], null, true ); + action = mwUriGetAction( this.href ); if ( action !== 'watch' && action !== 'unwatch' ) {