Ori.livneh has uploaded a new change for review.

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

Change subject: Pre-load the Wiki logo
......................................................................

Pre-load the Wiki logo

$wgLogo is rendered as the background-image of #p-logo rather than an <img>
tag. However, background-images are only loaded after all <img> tags in the
page HTML have been loaded. This causes the logo to render late, which is
annoying because it is visually prominent and above-the-fold. We work around
this by creating an Image node and setting its src to the logo URL, which
elevates its priority to that of an <img>.

Change-Id: Ie6f32fb846c70b262295abb79fb12fb20d40bc93
---
M includes/OutputPage.php
M includes/resourceloader/ResourceLoaderStartUpModule.php
M resources/Resources.php
A resources/src/mediawiki.skinning/mediawiki.skinning.js
4 files changed, 34 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/10/201610/1

diff --git a/includes/OutputPage.php b/includes/OutputPage.php
index cac89f4..8361b97 100644
--- a/includes/OutputPage.php
+++ b/includes/OutputPage.php
@@ -2264,6 +2264,7 @@
                        $coreModules = array(
                                // keep this list as small as possible
                                'mediawiki.page.startup',
+                               'mediawiki.skinning.interface',
                                'mediawiki.user',
                        );
 
diff --git a/includes/resourceloader/ResourceLoaderStartUpModule.php 
b/includes/resourceloader/ResourceLoaderStartUpModule.php
index 48b3576..719b807 100644
--- a/includes/resourceloader/ResourceLoaderStartUpModule.php
+++ b/includes/resourceloader/ResourceLoaderStartUpModule.php
@@ -103,6 +103,8 @@
                        'wgLegalTitleChars' => 
Title::convertByteClassToUnicodeClass( Title::legalChars() ),
                        'wgResourceLoaderStorageVersion' => $conf->get( 
'ResourceLoaderStorageVersion' ),
                        'wgResourceLoaderStorageEnabled' => $conf->get( 
'ResourceLoaderStorageEnabled' ),
+                       'wgLogo' => $conf->get( 'Logo' ),
+                       'wgLogoHD' => $conf->get( 'LogoHD' ),
                );
 
                Hooks::run( 'ResourceLoaderGetConfigVars', array( &$vars ) );
diff --git a/resources/Resources.php b/resources/Resources.php
index f9d2eac..b587b96 100644
--- a/resources/Resources.php
+++ b/resources/Resources.php
@@ -102,6 +102,9 @@
        ),
        'mediawiki.skinning.interface' => array(
                'class' => 'ResourceLoaderSkinModule',
+               'scripts' => array(
+                       
'resources/src/mediawiki.skinning/mediawiki.skinning.js',
+               ),
                // Used in the web installer. Test it after modifying this 
definition!
                'styles' => array(
                        'resources/src/mediawiki.skinning/elements.css' => 
array( 'media' => 'screen' ),
diff --git a/resources/src/mediawiki.skinning/mediawiki.skinning.js 
b/resources/src/mediawiki.skinning/mediawiki.skinning.js
new file mode 100644
index 0000000..8cbf0b7
--- /dev/null
+++ b/resources/src/mediawiki.skinning/mediawiki.skinning.js
@@ -0,0 +1,28 @@
+/**
+ * Pre-load the Wiki logo
+ *
+ * $wgLogo is rendered as the background-image of #p-logo rather than an <img>
+ * tag. However, background-images are only loaded after all <img> tags in the
+ * page HTML have been loaded. This causes the logo to render late, which is
+ * annoying because it is visually prominent and above-the-fold. We work around
+ * this by creating an Image node and setting its src to the logo URL, which
+ * elevates its priority to that of an <img>.
+ */
+/*global devicePixelRatio */
+( function ( mw ) {
+       var logos = mw.config.get( 'wgLogoHD', {} ),
+               bestLogo = mw.config.get( 'wgLogo' ),
+               bestRatio = 0, ratio, logo;
+
+       if ( window.devicePixelRatio > 1 ) {
+               for ( ratio in logos ) {
+                       logo = logos[ratio];
+                       ratio = parseFloat( ratio );
+                       if ( ratio > bestRatio && ratio <= devicePixelRatio ) {
+                               bestLogo = logo;
+                       }
+               }
+       }
+
+       new Image().src = bestLogo;
+} ( mediaWiki ) );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie6f32fb846c70b262295abb79fb12fb20d40bc93
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>

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

Reply via email to