X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fresourceloader%2FResourceLoaderClientHtml.php;h=ea35de6bea984b5927daa9d8cb5b58cc2961f211;hp=d59e1c8c9a017d8d49d96cfdfa8fb5afc188fdba;hb=e19e6bfabcaf2b6aa5dd837ff7057bd6a25baef8;hpb=ea2389164677fcf5469615077f1e8f839cae28fe diff --git a/includes/resourceloader/ResourceLoaderClientHtml.php b/includes/resourceloader/ResourceLoaderClientHtml.php index d59e1c8c9a..ea35de6bea 100644 --- a/includes/resourceloader/ResourceLoaderClientHtml.php +++ b/includes/resourceloader/ResourceLoaderClientHtml.php @@ -143,15 +143,15 @@ class ResourceLoaderClientHtml { $group = $module->getGroup(); $context = $this->getContext( $group, ResourceLoaderModule::TYPE_COMBINED ); - if ( $module->isKnownEmpty( $context ) ) { - // Avoid needless request or embed for empty module - $data['states'][$name] = 'ready'; - continue; - } + $shouldEmbed = $module->shouldEmbedModule( $this->context ); - if ( $group === 'user' || $module->shouldEmbedModule( $this->context ) ) { - // Call makeLoad() to decide how to load these, instead of - // loading via mw.loader.load(). + if ( ( $group === 'user' || $shouldEmbed ) && $module->isKnownEmpty( $context ) ) { + // This is a user-specific or embedded module, which means its output + // can be specific to the current page or user. As such, we can optimise + // the way we load it based on the current version of the module. + // Avoid needless embed for empty module, preset ready state. + $data['states'][$name] = 'ready'; + } elseif ( $group === 'user' || $shouldEmbed ) { // - For group=user: We need to provide a pre-generated load.php // url to the client that has the 'user' and 'version' parameters // filled in. Without this, the client would wrongly use the static @@ -187,15 +187,30 @@ class ResourceLoaderClientHtml { $group = $module->getGroup(); $context = $this->getContext( $group, ResourceLoaderModule::TYPE_STYLES ); - // Avoid needless request for empty module - if ( !$module->isKnownEmpty( $context ) ) { - if ( $module->shouldEmbedModule( $this->context ) ) { - // Embed via style element + if ( $module->shouldEmbedModule( $this->context ) ) { + // Avoid needless embed for private embeds we know are empty. + // (Set "ready" state directly instead, which we do a few lines above.) + if ( !$module->isKnownEmpty( $context ) ) { + // Embed via