From f22b3b81f9e30365536d4bc7b1b1bb827ae413fa Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Tue, 18 Sep 2018 00:48:14 +0100 Subject: [PATCH 1/1] resourceloader: Add internal RLPAGEMODULES constant Expose this constant for internal use by Navigation Timing, so that it can compute mwLoadEnd based on when these modules finish loading. The way mwLoadEnd is currently computed is by building a list of all registered module names, and narrowing it down to the ones in 'loading' state at the time that ext.navigationTiming.js executes. The problem with doing that, is that it is includes various lazy-loaded modules that aren't critical to the page and aren't meant to be tracked by that metric. For example: * Preloading of modules from various extensions (including VE, and Popups). * Background chains for EventLogging schemas from mw.loader.using, including the one started by Navigation Timing itself. On my local install, the list of filtered down modules always includes 'schema.SaveTiming', '...rumSpeedIndex', etc. Exporting the list passed to the initial load() call as constant will enable Navigation Timing to instead only await only those modules (and their dependneices). Bug: T204426 Change-Id: Ida134b4dfee218db16c2d1f88d4f26e8d761e154 --- includes/resourceloader/ResourceLoaderClientHtml.php | 5 ++++- .../includes/resourceloader/ResourceLoaderClientHtmlTest.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/includes/resourceloader/ResourceLoaderClientHtml.php b/includes/resourceloader/ResourceLoaderClientHtml.php index 8d0836640f..5c072bfdec 100644 --- a/includes/resourceloader/ResourceLoaderClientHtml.php +++ b/includes/resourceloader/ResourceLoaderClientHtml.php @@ -304,7 +304,10 @@ class ResourceLoaderClientHtml { // Inline RLQ: Load general modules if ( $data['general'] ) { $chunks[] = ResourceLoader::makeInlineScript( - Xml::encodeJsCall( 'mw.loader.load', [ $data['general'] ] ), + 'RLPAGEMODULES=' + . ResourceLoader::encodeJsonForScript( $data['general'] ) + . ';' + . 'mw.loader.load(RLPAGEMODULES);', $nonce ); } diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php index 7cd698354d..dbc757f90b 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php @@ -226,7 +226,7 @@ Deprecation message.' ] . 'mw.config.set({"key":"value"});' . 'mw.loader.state({"test.exempt":"ready","test.private":"loading","test.styles.pure":"ready","test.styles.private":"ready","test.styles.deprecated":"ready","test.scripts":"loading"});' . 'mw.loader.implement("test.private@{blankVer}",function($,jQuery,require,module){},{"css":[]});' - . 'mw.loader.load(["test"]);' + . 'RLPAGEMODULES=["test"];mw.loader.load(RLPAGEMODULES);' . 'mw.loader.load("/w/load.php?debug=false\u0026lang=nl\u0026modules=test.scripts\u0026only=scripts\u0026skin=fallback");' . '});' . "\n" . '' . "\n" -- 2.20.1