Page MenuHomePhabricator

Move mediawiki.special.js to a separate module
Closed, ResolvedPublic


The 'mediawiki.special' module defines

'scripts' => 'resources/mediawiki.special/mediawiki.special.js',
'styles' => 'resources/mediawiki.special/mediawiki.special.css',

but several special pages call only

$out->addModuleStyles( 'mediawiki.special' );

ignoring the JS. mediawiki.special.js currently only defines an mediaWiki.special namespace, so this is not causing any harm. Conversely, Special:RecentChanges does not addModuleStyles( 'mediawiki.special' ) and instead mentions it as a dependency of its script module, so it does not load mediawiki.special.css if JS is disabled; RecentPages doesn't seem to use any of the styles in mediawiki.special.css so again no harm.

I noticed this while researching how code handles addModule{s,Scripts,Styles}. Roan suggested that if code has CSS that should load when JS is disabled then it should be in a separate module to avoid this confusion, I don't see a naming convention for this (a '_nojs' suffix perhaps?).

Version: 1.22.0
Severity: minor



Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 1:30 AM
bzimport set Reference to bz47134.
bzimport added a subscriber: Unknown Object (MLST).
Aklapper lowered the priority of this task from Medium to Low.Mar 17 2015, 10:35 AM
Aklapper added a subscriber: Aklapper.
./includes/specials/SpecialStatistics.php:		$this->getOutput()->addModuleStyles( 'mediawiki.special' );
./includes/specials/SpecialPrefixindex.php:		$out->addModuleStyles( 'mediawiki.special' );
./includes/specials/SpecialBlockList.php:		$out->addModuleStyles( 'mediawiki.special' );
./includes/specials/SpecialEmailuser.php:		$out->addModuleStyles( 'mediawiki.special' );
./includes/specials/SpecialAllPages.php:		$out->addModuleStyles( 'mediawiki.special' );
./includes/specials/SpecialListgrouprights.php:		$out->addModuleStyles( 'mediawiki.special' );
./includes/specials/SpecialSpecialpages.php:		$out->addModuleStyles( 'mediawiki.special' );
./includes/specials/SpecialProtectedpages.php:		$this->getOutput()->addModuleStyles( 'mediawiki.special' );
./includes/specials/SpecialUserrights.php:		$out->addModuleStyles( 'mediawiki.special' );
./includes/specials/SpecialAllMessages.php:		$out->addModuleStyles( 'mediawiki.special' );
./includes/specials/SpecialContributions.php:		$out->addModuleStyles( 'mediawiki.special' );
Krinkle renamed this task from special pages inconsistently load mediawiki.special's JS or CSS to Move mediawiki.special.js to a separate module.Apr 28 2015, 6:37 PM
Krinkle set Security to None.
Krinkle added a project: Technical-Debt.
Krinkle removed a subscriber: Unknown Object (MLST).

There is no bug that I can see, though there is technical debt.

We never load "mediawiki.special" as a module, only as a stylesheet. So this is consistent.

The mediawiki.special.js file is for dependent modules, such as "mediawiki.special.recentchanges". This would likely cause the stylesheet to load a second time (T92747).

Krinkle moved this task from Backlog to Accepted Enhancement on the MediaWiki-ResourceLoader board.
Danny_B moved this task from Unsorted to Move on the Technical-Debt board.Jan 23 2016, 12:18 AM
Krinkle closed this task as Resolved.Aug 5 2016, 2:39 AM
Krinkle claimed this task.