*
* - Beware: This file MUST parse without errors on even the most ancient of browsers!
*/
-/* eslint-disable no-implicit-globals, vars-on-top, no-unmodified-loop-condition */
-/* global $VARS, $CODE */
+/* eslint-disable no-implicit-globals */
+/* global $VARS, $CODE, RLQ:true, NORLQ:true */
/**
* See <https://www.mediawiki.org/wiki/Compatibility#Browsers>
//
// Please extend the regex instead of adding new ones!
// And add a test case to startup.test.js
- !ua.match( /MSIE 10|webOS\/1\.[0-4]|SymbianOS|Series60|NetFront|Opera Mini|S40OviBrowser|MeeGo|Android.+Glass|^Mozilla\/5\.0 .+ Gecko\/$|googleweblight|PLAYSTATION|PlayStation/ )
+ !ua.match( /MSIE 10|webOS\/1\.[0-4]|SymbianOS|NetFront|Opera Mini|S40OviBrowser|MeeGo|Android.+Glass|^Mozilla\/5\.0 .+ Gecko\/$|googleweblight|PLAYSTATION|PlayStation/ )
);
}
.replace( /(^|\s)client-js(\s|$)/, '$1client-nojs$2' );
// Process any callbacks for Grade C
- while ( window.NORLQ && window.NORLQ[ 0 ] ) {
- window.NORLQ.shift()();
+ while ( window.NORLQ && NORLQ[ 0 ] ) {
+ NORLQ.shift()();
}
- window.NORLQ = {
+ NORLQ = {
push: function ( fn ) {
fn();
}
};
// Clear and disable the Grade A queue
- window.RLQ = {
+ RLQ = {
push: function () {}
};
} else {
*/
( function () {
/* global mw */
- mw.config = new mw.Map( $VARS.wgLegacyJavaScriptGlobals );
$CODE.registrations();
mw.config.set( $VARS.configuration );
+ // For the current page
+ mw.config.set( window.RLCONF || {} );
+ mw.loader.state( window.RLSTATE || {} );
+ mw.loader.load( window.RLPAGEMODULES || [] );
- // Process callbacks for Grade A
- var queue = window.RLQ;
- // Replace RLQ placeholder from ResourceLoaderClientHtml with an implementation
- // that executes simple callbacks, but continues to store callbacks that require
- // modules.
- window.RLQ = [];
- /* global RLQ */
+ // Process RLQ callbacks
+ //
+ // The code in these callbacks could've been exposed from load.php and
+ // requested client-side. Instead, they are pushed by the server directly
+ // (from ResourceLoaderClientHtml and other parts of MediaWiki). This
+ // saves the need for additional round trips. It also allows load.php
+ // to remain stateless and sending personal data in the HTML instead.
+ //
+ // The HTML inline script lazy-defines the 'RLQ' array. Now that we are
+ // processing it, replace it with an implementation where 'push' actually
+ // considers executing the code directly. This is to ensure any late
+ // arrivals will also be processed. Late arrival can happen because
+ // startup.js is executed asynchronously, concurrently with the streaming
+ // response of the HTML.
+ RLQ = window.RLQ || [];
RLQ.push = function ( fn ) {
if ( typeof fn === 'function' ) {
fn();
} else {
- // This callback requires a module, handled in mediawiki.base.
+ // If the first parameter is not a function, then it is an array
+ // containing a list of required module names and a function.
+ // Do an actual push for now, as this signature is handled
+ // later by mediawiki.base.js.
RLQ[ RLQ.length ] = fn;
}
};
- while ( queue && queue[ 0 ] ) {
- // Re-use our new push() method
- RLQ.push( queue.shift() );
+ while ( RLQ[ 0 ] ) {
+ // Process all values gathered so far
+ RLQ.push( RLQ.shift() );
}
// Clear and disable the Grade C queue
- window.NORLQ = {
+ NORLQ = {
push: function () {}
};
}() );