resourceloader: Move mwNow() to after isCompatible()
authorTimo Tijhof <krinklemail@gmail.com>
Tue, 18 Apr 2017 21:13:06 +0000 (14:13 -0700)
committerTimo Tijhof <krinklemail@gmail.com>
Tue, 18 Apr 2017 21:14:54 +0000 (14:14 -0700)
Follows-up f2fb4a21af. This is logically still the same point in time.
Only 1 function before it now, isCompatible(), which is fine since it
is small and the variable is not used anyway if it returns false.

Change-Id: I34bbe8edf6e9625f8d80f829707adafcb1b91980

resources/src/startup.js

index ad06b34..e0df772 100644 (file)
@@ -1,7 +1,8 @@
 /**
- * Code in this file MUST work on even the most ancient of browsers!
+ * This file is where we decide whether to initialise the Grade A run-time.
  *
- * This file is where we decide whether to initialise the modern run-time.
+ * - Beware: This file MUST parse without errors on even the most ancient of browsers!
+ * - Beware: Do not call mwNow before the isCompatible() check.
  */
 
 /* global mw, $VARS, $CODE */
@@ -18,9 +19,7 @@ var mwPerformance = ( window.performance && performance.mark ) ? performance : {
                        function () { return Date.now(); };
        }() ),
        // eslint-disable-next-line no-unused-vars
-       mediaWikiLoadStart = mwNow();
-
-mwPerformance.mark( 'mwLoadStart' );
+       mediaWikiLoadStart;
 
 /**
  * See <https://www.mediawiki.org/wiki/Compatibility#Browsers>
@@ -153,6 +152,9 @@ function isCompatible( str ) {
                };
        }
 
+       mediaWikiLoadStart = mwNow();
+       mwPerformance.mark( 'mwLoadStart' );
+
        script = document.createElement( 'script' );
        script.src = $VARS.baseModulesUri;
        script.onload = script.onreadystatechange = function () {