Page MenuHomePhabricator

Split mediawiki.special.css file
Closed, DeclinedPublic

Description

mediawiki.special.css contains CSS for many different special modules.. As it's not reused, we should really split these down into css files per SpecialPage, so we're not serving more CSS to a specific special page than we need to

It looks like this will be 17 or 18 different css files...

Weirder still, Special:UserRights has CSS in mediawiki.special.css and mediawiki.special.userrights.css. Then we add 2 different modules to the special page

I think most don't have their own CSS files already, but some others do have their own JS.. So they have part of the module etc...

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change 392313 had a related patch set uploaded (by Reedy; owner: Reedy):
[mediawiki/core@master] Move Specia:UserRights css to existing css module

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

mediawiki.special is a style module and get loaded via addModuleStyles to prevent a FOUC on loading. When the CSS styles are moved to other files the new module must also get loaded via addModuleStyles.

Is it wise to spit up the big style module mediawiki.special into several small style modules? This increases the number of modules. The names of all modules get loaded on every page.

Change 392313 merged by jenkins-bot:
[mediawiki/core@master] Move styles for Special:UserRights to separate style module

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

@Fomafix Indeed. I mentioned the same earlier to Reedy on IRC. Combined modules are not always a bad thing. And separate modules can sometimes cause more harm than good. I would say that in its current size this file is not adding significant burden to special pages it is loaded on.

That is not to say that it has to stay this way. If there is a more suitable module in existence loaded on the same special page, and if it would allow the "mediawiki.special" module to be removed from that page, then by all means, we can move the styles elsewhere. But I don't think removing the module entirely would be an improvement.

An alternative without increasing the number of modules but separating the styles to different files is, to split up the file mediawiki.special.css into several CSS files per special page but keep the module name mediawiki.special and add all CSS files to this module.

It would be nice when it would be possible to use the same module name for style modules and for normal modules. This would reduce the number of modules. Is there a task for such a feature?

It would be nice when it would be possible to use the same module name for style modules and for normal modules. This would reduce the number of modules. Is there a task for such a feature?

I am not sure what you mean with "use the same module name for style modules and for normal modules". Can you clarify?

Change 392773 had a related patch set uploaded (by Krinkle; owner: Fomafix):
[mediawiki/core@master] Merge mediawiki.special.userrights.styles into mediawiki.special

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

Change 392773 merged by jenkins-bot:
[mediawiki/core@master] Merge mediawiki.special.userrights.styles into mediawiki.special

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

Currently we have two modules, a normal module and a style module:

	'foo' => [
		'scripts' => 'foo.js',
		'styles' => 'foo.css',
		'dependencies' => [
			'bar',
		],
	],
	'foo.styles' => [
		'styles' => 'foo.styles.css',
	],

and add them via addModules( 'foo' ); and addModuleStyles( 'foo.styles' );.

I like to have one module with one name:

	'foo' => [
		'scripts' => 'foo.js',
		'styles' => 'foo.css',
		'topstyles' => 'foo.styles.css',
		'dependencies' => [
			'bar',
		],
	],

and add them via addModules( 'foo' ); and addModuleStyles( 'foo' );.

This would reduce the number of module names.

I'm wondering if we just do like Timo did in https://gerrit.wikimedia.org/r/#/c/392773/ - Split the CSS down into files per special page, but don't actually add any more RL modules?

So repurpose the bug slightly?

Krinkle renamed this task from Split mediawiki.special.css to Split mediawiki.special.css file.Dec 15 2017, 1:44 AM

Spawning off a lot of modules had the intention of organising code better. That has happened already to some extent by using separate files instead of separate modules.

There was a thought at some point in CR that separate modules would perform better but splitting up the 1KB (before compression) of CSS is not worth any amount of fragmentation. The global global overhead it would bring to the hot and heavy startup module would deter performance, as well as reducing chances of cache hits overall (sometimes loading a tiny bit of unused code is overall beneficial, as otherwise every page view would be unique and hard to cache).