Preload mediawiki.notification when we know we're going to need it soon
authorBartosz Dziewoński <matma.rex@gmail.com>
Sat, 15 Feb 2014 16:17:08 +0000 (17:17 +0100)
committerOri.livneh <ori@wikimedia.org>
Wed, 19 Feb 2014 08:59:45 +0000 (08:59 +0000)
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

resources/mediawiki.page/mediawiki.page.patrol.ajax.js
resources/mediawiki.page/mediawiki.page.watch.ajax.js

index 75908ee..5fb14dd 100644 (file)
@@ -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',
index 998a8c2..9489403 100644 (file)
                $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' ) {