jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/365889 )
Change subject: resourceloader: Preload base modules request from startup module ...................................................................... resourceloader: Preload base modules request from startup module This allows browsers that support W3C Preload <https://www.w3.org/TR/preload/>, to start downloading and parsing the second load.php JavaScript request as soon as the headers of the startup module arrive. Before: - HTML request, response start. |\- Discover <script src async> for startup.js, request, response start. | \ - Startup response end, JS parsing. | | |__|- HTML parsing and rendering yields for async JS execution. \- JavaScript inserts <script>, Base-modules request starts. <<< After: - HTML request, response start. |\- Discover <script src async> for startup.js, request, response start \ - Base-modules request starts. <<< | |- Startup response end, JS parsing. | | |__|- HTML parsing and rendering yields for async JS execution. \- JavaScript inserts <script>. (Base-modules req on-going, or done) On local testing with "Slow 3G" network throttling in Chrome, this reduced page load time (window.onload, time to interaction for JS) by about 1 second (from 14s to 13s). See also https://phabricator.wikimedia.org/T164299#3572231 Bug: T164299 Change-Id: I7047f4ab881947cf3392256087cc5a0cb177dd3a --- M includes/resourceloader/ResourceLoaderStartUpModule.php 1 file changed, 11 insertions(+), 0 deletions(-) Approvals: jenkins-bot: Verified Gilles: Looks good to me, approved diff --git a/includes/resourceloader/ResourceLoaderStartUpModule.php b/includes/resourceloader/ResourceLoaderStartUpModule.php index 8973fe3..d535ffc 100644 --- a/includes/resourceloader/ResourceLoaderStartUpModule.php +++ b/includes/resourceloader/ResourceLoaderStartUpModule.php @@ -297,6 +297,16 @@ } /** + * @return array + */ + public function getPreloadLinks( ResourceLoaderContext $context ) { + $url = self::getStartupModulesUrl( $context ); + return [ + $url => [ 'as' => 'script' ] + ]; + } + + /** * Base modules required for the base environment of ResourceLoader * * @return array @@ -359,6 +369,7 @@ }, [ '$VARS.wgLegacyJavaScriptGlobals' => $this->getConfig()->get( 'LegacyJavaScriptGlobals' ), '$VARS.configuration' => $this->getConfigSettings( $context ), + // This url may be preloaded. See getPreloadLinks(). '$VARS.baseModulesUri' => self::getStartupModulesUrl( $context ), ] ); $pairs['$CODE.registrations()'] = str_replace( -- To view, visit https://gerrit.wikimedia.org/r/365889 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I7047f4ab881947cf3392256087cc5a0cb177dd3a Gerrit-PatchSet: 5 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Krinkle <[email protected]> Gerrit-Reviewer: Catrope <[email protected]> Gerrit-Reviewer: Gilles <[email protected]> Gerrit-Reviewer: Legoktm <[email protected]> Gerrit-Reviewer: Phedenskog <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
