From: Ori Livneh Date: Fri, 17 Jul 2015 21:46:03 +0000 (-0500) Subject: Make the User Timing API safe to use in MediaWiki X-Git-Tag: 1.31.0-rc.0~10697^2 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=7076ee791fe3e991e2a0f8ab17f6bf3fab92df57;p=lhc%2Fweb%2Fwiklou.git Make the User Timing API safe to use in MediaWiki Allow JavaScript code to be annotated via the User Timing API without having to repeatedly ensure that the API exists by declaring a no-op stub for browsers that don't implement it. Do it in the startup module so we can use performance.mark() early. Add an initial performance.mark() call as a use-case. Task: T105389 Change-Id: Id686073da5baf3fcae36f296e6e50d648a543249 --- diff --git a/.jshintrc b/.jshintrc index d72c31d66f..b84d276621 100644 --- a/.jshintrc +++ b/.jshintrc @@ -22,6 +22,7 @@ "mediaWiki": true, "JSON": true, "OO": true, + "performance": true, "jQuery": false, "QUnit": false, "sinon": false diff --git a/resources/src/startup.js b/resources/src/startup.js index 80cc7d935a..5ee295bd91 100644 --- a/resources/src/startup.js +++ b/resources/src/startup.js @@ -6,6 +6,14 @@ var mediaWikiLoadStart = ( new Date() ).getTime(); +if ( !window.performance ) { + window.performance = {}; +} +if ( !performance.mark ) { + performance.mark = function () {}; +} +performance.mark( 'mediaWikiStartUp' ); + /** * Returns false for Grade C supported browsers. *