Gilles has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/206831

Change subject: [WIP] Add ability to load plain CSS files at the bottom
......................................................................

[WIP] Add ability to load plain CSS files at the bottom

This will be useful for mobile web in no-JS mode, where currently
all the CSS is being needlessly loaded in the head.

TODO: make all existing CSS modules currently loading in the head
do so explicitly and turn "forcebottom" into "bottom".

Bug: T97289
Change-Id: Ie4287e17d6f298cc63f42f257b1f67ee36961b77
---
M includes/OutputPage.php
M includes/resourceloader/ResourceLoaderImageModule.php
2 files changed, 20 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/31/206831/1

diff --git a/includes/OutputPage.php b/includes/OutputPage.php
index 28d55e4..27e9954 100644
--- a/includes/OutputPage.php
+++ b/includes/OutputPage.php
@@ -3031,6 +3031,11 @@
                        /* $loadCall = */ $inHead
                );
 
+               $links[] = $this->makeResourceLoaderLink( 
$this->getModuleStyles( true, 'forcebottom' ),
+                       ResourceLoaderModule::TYPE_STYLES, /* $useESI = */ 
false, /* $extraQuery = */ array(),
+                       /* $loadCall = */ $inHead
+               );
+
                // Modules requests - let the client calculate dependencies and 
batch requests as it likes
                // Only load modules that have marked themselves for loading at 
the bottom
                $modules = $this->getModules( true, 'bottom' );
@@ -3088,6 +3093,9 @@
         * @return string
         */
        function getBottomScripts() {
+               // In case the skin wants to add bottom CSS
+               $this->getSkin()->setupSkinUserCss( $this );
+
                // Optimise jQuery ready event cross-browser.
                // This also enforces $.isReady to be true at </body> which 
fixes the
                // mw.loader bug in Firefox with using document.write between 
</body>
@@ -3600,6 +3608,10 @@
                $resourceLoader = $this->getResourceLoader();
 
                $moduleStyles = $this->getModuleStyles();
+               // Most CSS modules are "bottom" by default, by virtue of 
ResourceLoaderModule, despite
+               // being very much in the head in this context
+               // TODO: make CSS modules loaded in the head explicitely so
+               $moduleStyles = array_diff( $moduleStyles, 
$this->getModuleStyles( true, 'forcebottom' ) );
 
                // Per-site custom styles
                $moduleStyles[] = 'site';
diff --git a/includes/resourceloader/ResourceLoaderImageModule.php 
b/includes/resourceloader/ResourceLoaderImageModule.php
index 7efdb26..e669c38 100644
--- a/includes/resourceloader/ResourceLoaderImageModule.php
+++ b/includes/resourceloader/ResourceLoaderImageModule.php
@@ -43,6 +43,9 @@
        protected $selectorWithVariant = '.{prefix}-{name}-{variant}';
        protected $targets = array( 'desktop', 'mobile' );
 
+       /** @var string Position on the page to load this module at */
+       protected $position = 'top';
+
        /**
         * Constructs a new module from an options array.
         *
@@ -130,6 +133,7 @@
                                case 'prefix':
                                case 'selectorWithoutVariant':
                                case 'selectorWithVariant':
+                               case 'position':
                                        $this->{$member} = (string)$option;
                                        break;
 
@@ -367,4 +371,8 @@
 
                return $localBasePath;
        }
+
+       public function getPosition() {
+               return $this->position;
+       }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/206831
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie4287e17d6f298cc63f42f257b1f67ee36961b77
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Gilles <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to