Skins: getDefaultStyles can now define render blocking CSS
[lhc/web/wiklou.git] / includes / skins / Skin.php
index 80a1f6e..9c4ac50 100644 (file)
@@ -166,17 +166,20 @@ abstract class Skin extends ContextSource {
         * It is recommended that skins wishing to override call parent::getDefaultModules()
         * and substitute out any modules they wish to change by using a key to look them up
         *
-        * For style modules, use setupSkinUserCss() instead.
+        * Any modules defined with the 'styles' key will be added as render blocking CSS via
+        * Output::addModuleStyles. Similarly, each key should refer to a list of modules
         *
         * @return array Array of modules with helper keys for easy overriding
         */
        public function getDefaultModules() {
-               global $wgUseAjax;
-
                $out = $this->getOutput();
                $config = $this->getConfig();
                $user = $out->getUser();
                $modules = [
+                       // Styles key sets render blocking styles
+                       // Unlike other keys in this definition it is an associative array
+                       // where each key is the group name and points to a list of modules
+                       'styles' => [],
                        // modules not specific to any specific skin or page
                        'core' => [
                                // Enforce various default modules for all pages and all skins
@@ -217,17 +220,15 @@ abstract class Skin extends ContextSource {
                }
 
                // Add various resources if required
-               if ( $wgUseAjax ) {
-                       if ( $user->isLoggedIn()
-                               && $user->isAllowedAll( 'writeapi', 'viewmywatchlist', 'editmywatchlist' )
-                               && $this->getRelevantTitle()->canExist()
-                       ) {
-                               $modules['watch'][] = 'mediawiki.page.watch.ajax';
-                       }
-
-                       $modules['search'][] = 'mediawiki.searchSuggest';
+               if ( $user->isLoggedIn()
+                       && $user->isAllowedAll( 'writeapi', 'viewmywatchlist', 'editmywatchlist' )
+                       && $this->getRelevantTitle()->canExist()
+               ) {
+                       $modules['watch'][] = 'mediawiki.page.watch.ajax';
                }
 
+               $modules['search'][] = 'mediawiki.searchSuggest';
+
                if ( $user->getBoolOption( 'editsectiononrightclick' ) ) {
                        $modules['user'][] = 'mediawiki.action.view.rightClickEdit';
                }