2 * This script provides a function which is run to evaluate whether or not to
3 * continue loading jQuery and the MediaWiki modules. This code should work on
4 * even the most ancient of browsers, so be very careful when editing.
7 var mediaWikiLoadStart
= ( new Date() ).getTime();
9 if ( !window
.performance
) {
10 window
.performance
= {};
12 if ( !performance
.mark
) {
13 performance
.mark = function () {};
15 performance
.mark( 'mwLoadStart' );
18 * Returns false for Grade C supported browsers.
20 * This function should only be used by the Startup module, do not expand it to
21 * be generally useful beyond startup.
24 * - https://www.mediawiki.org/wiki/Compatibility#Browsers
25 * - https://jquery.com/browser-support/
28 /*jshint unused: false, evil: true */
29 /*globals mw, RLQ: true, $VARS, $CODE */
30 function isCompatible( ua
) {
31 if ( ua
=== undefined ) {
32 ua
= navigator
.userAgent
;
35 // Browsers with outdated or limited JavaScript engines get the no-JS experience
37 // Internet Explorer < 8
38 ( ua
.indexOf( 'MSIE' ) !== -1 && parseFloat( ua
.split( 'MSIE' )[ 1 ] ) < 8 ) ||
40 ( ua
.indexOf( 'Firefox/' ) !== -1 && parseFloat( ua
.split( 'Firefox/' )[ 1 ] ) < 3 ) ||
42 ( ua
.indexOf( 'Opera/' ) !== -1 && ( ua
.indexOf( 'Version/' ) === -1 ?
44 parseFloat( ua
.split( 'Opera/' )[ 1 ] ) < 10 :
45 // "Opera/9.80 ... Version/x.y"
46 parseFloat( ua
.split( 'Version/' )[ 1 ] ) < 12
48 // "Mozilla/0.0 ... Opera x.y"
49 ( ua
.indexOf( 'Opera ' ) !== -1 && parseFloat( ua
.split( ' Opera ' )[ 1 ] ) < 10 ) ||
51 ua
.match( /BlackBerry[^\/]*\/[1-5]\./ ) ||
53 ua
.match( /webOS\/1\.[0-4]/ ) ||
54 // Anything PlayStation based.
55 ua
.match( /PlayStation/i ) ||
56 // Any Symbian based browsers
57 ua
.match( /SymbianOS|Series60/ ) ||
58 // Any NetFront based browser
59 ua
.match( /NetFront/ ) ||
60 // Opera Mini, all versions
61 ua
.match( /Opera Mini/ ) ||
62 // Nokia's Ovi Browser
63 ua
.match( /S40OviBrowser/ ) ||
65 ua
.match( /MeeGo/ ) ||
66 // Google Glass browser groks JS but UI is too limited
67 ( ua
.match( /Glass/ ) && ua
.match( /Android/ ) )
71 // Conditional script injection
73 if ( !isCompatible() ) {
74 // Undo class swapping in case of an unsupported browser.
75 // See OutputPage::getHeadScripts().
76 document
.documentElement
.className
= document
.documentElement
.className
77 .replace( /(^|\s)client-js(\s|$)/, '$1client-nojs$2' );
82 * The $CODE and $VARS placeholders are substituted in ResourceLoaderStartUpModule.php.
85 mw
.config
= new mw
.Map( $VARS
.wgLegacyJavaScriptGlobals
);
87 $CODE
.registrations();
89 mw
.config
.set( $VARS
.configuration
);
91 // Must be after mw.config.set because these callbacks may use mw.loader which
92 // needs to have values 'skin', 'debug' etc. from mw.config.
93 window
.RLQ
= window
.RLQ
|| [];
94 while ( RLQ
.length
) {
98 push: function ( fn
) {
104 var script
= document
.createElement( 'script' );
105 script
.src
= $VARS
.baseModulesUri
;
106 script
.onload
= script
.onreadystatechange = function () {
107 if ( !script
.readyState
|| /loaded|complete/.test( script
.readyState
) ) {
109 script
.onload
= script
.onreadystatechange
= null;
115 document
.getElementsByTagName( 'head' )[ 0 ].appendChild( script
);