Krinkle has uploaded a new change for review. https://gerrit.wikimedia.org/r/227373
Change subject: [WIP] resourceloader: Convert inline statements to queued functions ...................................................................... [WIP] resourceloader: Convert inline statements to queued functions Instead of having inline statements be plain statements wrapped in an if-conditional block, convert them to inline functions pushed into a queue. The queue is kept in-memory until the startup module is loaded at which point it transforms into a function that is immediately invoked. This is in preparation of Change-Id: Ifb38efca219c10ab973ad4c4ebb21c6a4239b005 --- M includes/OutputPage.php M includes/resourceloader/ResourceLoader.php M resources/src/startup.js 3 files changed, 20 insertions(+), 8 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/73/227373/1 diff --git a/includes/OutputPage.php b/includes/OutputPage.php index a551fe1..dd3d7fe 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -3004,12 +3004,6 @@ // Separate user.tokens as otherwise caching will be allowed (T84960) $links[] = $this->makeResourceLoaderLink( 'user.tokens', ResourceLoaderModule::TYPE_COMBINED ); - // Scripts and messages "only" requests marked for top inclusion - $links[] = $this->makeResourceLoaderLink( - $this->getModuleScripts( true, 'top' ), - ResourceLoaderModule::TYPE_SCRIPTS - ); - // Modules requests - let the client calculate dependencies and batch requests as it likes // Only load modules that have marked themselves for loading at the top $modules = $this->getModules( true, 'top' ); @@ -3019,6 +3013,12 @@ ); } + // "Scripts only" modules marked for top inclusion + $links[] = $this->makeResourceLoaderLink( + $this->getModuleScripts( true, 'top' ), + ResourceLoaderModule::TYPE_SCRIPTS + ); + if ( $this->getConfig()->get( 'ResourceLoaderExperimentalAsyncLoading' ) ) { $links[] = $this->getScriptsForBottomQueue( true ); } diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php index 508be2f..09556cc 100644 --- a/includes/resourceloader/ResourceLoader.php +++ b/includes/resourceloader/ResourceLoader.php @@ -1368,7 +1368,9 @@ * @return string */ public static function makeLoaderConditionalScript( $script ) { - return "if(window.mw){\n" . trim( $script ) . "\n}"; + return ResourceLoader::inDebugMode() + ? "var RLQ = RLQ || []; RLQ.push( function () {\n" . trim( $script ) . "\n} );" + : 'var RLQ=RLQ||[];RLQ.push(function(){' . trim( $script ) . '});'; } /** diff --git a/resources/src/startup.js b/resources/src/startup.js index ac42854..1332459 100644 --- a/resources/src/startup.js +++ b/resources/src/startup.js @@ -26,7 +26,7 @@ */ /*jshint unused: false, evil: true */ -/*globals mw, $VARS, $CODE */ +/*globals mw, RLQ: true, $VARS, $CODE */ function isCompatible( ua ) { if ( ua === undefined ) { ua = navigator.userAgent; @@ -76,6 +76,16 @@ $CODE.registrations(); + window.RLQ = window.RLQ || []; + while ( RLQ.length ) { + RLQ.shift()(); + } + RLQ = { + push: function ( fn ) { + fn(); + } + }; + mw.config.set( $VARS.configuration ); } -- To view, visit https://gerrit.wikimedia.org/r/227373 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ifb38efca219c10ab973ad4c4ebb21c6a4239b005 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Krinkle <krinklem...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits