resourceloader: Introduce window.NORLQ
authorAlex Monk <krenair@wikimedia.org>
Sat, 23 Jan 2016 00:15:56 +0000 (00:15 +0000)
committerKrinkle <krinklemail@gmail.com>
Tue, 9 Feb 2016 19:10:38 +0000 (19:10 +0000)
Bug: T123457
Change-Id: Ice6ebb95bfcb2050f4813705467942f95f7e720c

resources/src/startup.js

index 0c2d6d6..e53e5f3 100644 (file)
@@ -4,7 +4,7 @@
  * even the most ancient of browsers, so be very careful when editing.
  */
 /*jshint unused: false, evil: true */
-/*globals mw, RLQ: true, $VARS, $CODE, performance */
+/*globals mw, RLQ: true, NORLQ: true, $VARS, $CODE, performance */
 
 var mediaWikiLoadStart = ( new Date() ).getTime(),
 
@@ -67,11 +67,29 @@ function isCompatible( ua ) {
 
 // Conditional script injection
 ( function () {
+       var NORLQ, script;
        if ( !isCompatible() ) {
                // Undo class swapping in case of an unsupported browser.
                // See OutputPage::getHeadScripts().
                document.documentElement.className = document.documentElement.className
                        .replace( /(^|\s)client-js(\s|$)/, '$1client-nojs$2' );
+
+               NORLQ = window.NORLQ || [];
+               while ( NORLQ.length ) {
+                       NORLQ.shift()();
+               }
+               window.NORLQ = {
+                       push: function ( fn ) {
+                               fn();
+                       }
+               };
+
+               // Clear and disable the other queue
+               window.RLQ = {
+                       // No-op
+                       push: function () {}
+               };
+
                return;
        }
 
@@ -96,9 +114,15 @@ function isCompatible( ua ) {
                                fn();
                        }
                };
+
+               // Clear and disable the other queue
+               window.NORLQ = {
+                       // No-op
+                       push: function () {}
+               };
        }
 
-       var script = document.createElement( 'script' );
+       script = document.createElement( 'script' );
        script.src = $VARS.baseModulesUri;
        script.onload = script.onreadystatechange = function () {
                if ( !script.readyState || /loaded|complete/.test( script.readyState ) ) {