Vector: Don't create an extra request for skins.vector module
authorTimo Tijhof <ttijhof@wikimedia.org>
Wed, 6 Mar 2013 01:31:08 +0000 (02:31 +0100)
committerKrinkle <ttijhof@wikimedia.org>
Wed, 6 Mar 2013 01:33:47 +0000 (01:33 +0000)
Blank MediaWiki page:

head>
 load.php:startup
 load([ top ])
body>
 load.php:skins.vector&only=scripts
 load([ bottom ])

Skin styles are loaded outside ResourceLoader from the <head>
(so they don't wait for startup, and don't rely on javascript).
Fair enough for basic page styling.

Then the real `mw.loader`-able part of the module should be
separated. There is no reason for it to also be loaded outside
`mw.loader`.

Change-Id: Ife69c5a443aac9eec8c2ec06d986b53b2379816f

resources/Resources.php
skins/Vector.php

index 562c176..d40e845 100644 (file)
@@ -26,7 +26,9 @@ if( !defined( 'MEDIAWIKI' ) ) {
 
 return array(
 
-       /* Special modules who have their own classes */
+       /**
+        * Special modules who have their own classes
+        */
 
        // Scripts managed by the local wiki (stored in the MediaWiki namespace)
        'site' => array( 'class' => 'ResourceLoaderSiteModule' ),
@@ -48,7 +50,16 @@ return array(
        // Scripts for the dynamic language specific data, like grammar forms.
        'mediawiki.language.data' => array( 'class' => 'ResourceLoaderLanguageDataModule' ),
 
-       /* Skins */
+       /**
+        * Skins
+        * Be careful not to add 'scripts' to these modules,
+        * since they are loaded with OutputPage::addModuleStyles so that the skin styles
+        * apply without javascript.
+        * If a skin needs custom js in the interface, register a separate module
+        * and add it to the load queue with OutputPage::addModules.
+        *
+        * See Vector for an example.
+        */
 
        'skins.chick' => array(
                'styles' => array( 'chick/main.css' => array( 'media' => 'screen, handheld' ) ),
@@ -102,6 +113,10 @@ return array(
                        'vector/screen.css' => array( 'media' => 'screen' ),
                        'vector/screen-hd.css' => array( 'media' => 'screen and (min-width: 982px)' ),
                ),
+               'remoteBasePath' => $GLOBALS['wgStylePath'],
+               'localBasePath' => $GLOBALS['wgStyleDirectory'],
+       ),
+       'skins.vector.js' => array(
                'scripts' => 'vector/vector.js',
                'remoteBasePath' => $GLOBALS['wgStylePath'],
                'localBasePath' => $GLOBALS['wgStyleDirectory'],
index 3e01d23..d0f9995 100644 (file)
@@ -57,7 +57,7 @@ class SkinVector extends SkinTemplate {
                                "/{$this->stylename}/csshover{$min}.htc\")}</style><![endif]-->"
                );
 
-               $out->addModuleScripts( 'skins.vector' );
+               $out->addModules( 'skins.vector.js' );
        }
 
        /**