From de862298032c6567785842e031239424fadaf1ad Mon Sep 17 00:00:00 2001 From: Ori Livneh Date: Tue, 1 Sep 2015 11:40:27 -0700 Subject: [PATCH] Deprecate unconditional loading of mediawiki.ui.button on all pages Formally deprecate the unconditional loading of mediawiki.ui.button on all pages. During the deprecation period, the styles will be loaded on pages which contain 'mw-ui-button' in the page HTML. Starting with 1.28, the styles will only be loaded if explicitly depended upon. The rationale for the patch was expressed by Spage in a comment on PS4 of I835f3eb937: "Wikis have too many templates like [[commons:Template:Clickable_button]] dependent on jquery.ui.button that don't work if JavaScript isn't enabled. mediawiki.ui.button is a lighter-weight piece of CSS that we own and can improve, and transitioning wiki content to it requires that we provide it." Mattflaschen commented that the added payload was "justifiable if we announce this widely and make an effort to get wikis to use this." A year and a half later, [[commons:Template:Clickable_button]] is still not using mediawiki.ui.button, and usage elsewhere is not sufficiently widespread to merit loading this stylesheet in the critical path. Bug: T98395 Change-Id: I290e1db422b7c7b9c1a026aae22e174580cefae9 --- RELEASE-NOTES-1.26 | 4 ++++ includes/skins/SkinTemplate.php | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES-1.26 b/RELEASE-NOTES-1.26 index 5b85bbcc7e..6dcf9195a1 100644 --- a/RELEASE-NOTES-1.26 +++ b/RELEASE-NOTES-1.26 @@ -66,6 +66,10 @@ production. for potentially slow POST requests that need to be as atomic as possible. * ResourceLoader now loads all scripts asynchronously. The top-queue and startup modules are no longer synchronously loaded. +* 'mediawiki.ui.button' styles are no longer unconditionally loaded on every + page. During the deprecation period, the styles will only be loaded on pages + which contain 'mw-ui-button' in their HTML. Starting in 1.28, the styles will + only be loaded if explicitly required. ==== External libraries ==== * Update es5-shim from v4.0.0 to v4.1.5. diff --git a/includes/skins/SkinTemplate.php b/includes/skins/SkinTemplate.php index a1844a81b2..baf9d95478 100644 --- a/includes/skins/SkinTemplate.php +++ b/includes/skins/SkinTemplate.php @@ -54,12 +54,18 @@ class SkinTemplate extends Skin { $moduleStyles = array( 'mediawiki.legacy.shared', 'mediawiki.legacy.commonPrint', - 'mediawiki.ui.button', 'mediawiki.sectionAnchor' ); if ( $out->isSyndicated() ) { $moduleStyles[] = 'mediawiki.feedlink'; } + + // Deprecated since 1.26: Unconditional loading of mediawiki.ui.button + // on every page is deprecated. Express a dependency instead. + if ( strpos( $out->getHTML(), 'mw-ui-button' ) !== false ) { + $moduleStyles[] = 'mediawiki.ui.button'; + } + $out->addModuleStyles( $moduleStyles ); } -- 2.20.1