Background
Modules in ResourceLoader are allowed to vary by language and skin. This is why conditionally loaded scripts are not registered as their own module each, but rather as a single module that varies as necessary.
For example, moment and jquery.ui.datepicker vary by language but register only a single publicly loadable bundle, which ships additional scripts as needed based on the context.
Using the same principal, skins augment modules from core and extensions through $wgResourceModuleSkinStyles.
Problem
The startup manifest of loadable bundles for the current context contains all skins, yet it is very unlikely one would want to lazy-load the main stylesheet of skin X on a page view for skin Y.
Rather than having the startup manifest grow linearly based on the number of registered skins, it should only register modules for the current skin.
Outcome
The extension registry and MW configuration will:
- allow skins to register modules in a way that allows RL to know they are "skin modules".
- encourage skins to register only one style module, whilst also allowing additional ones to be registered.
Proposal
Developer facing:
- New attribute SkinModule - takes which the form like a single entry in ResourceModules. Process and registered as a standard module called "skin". This is similar to the recently introduced QUnitTestModule attribute, in that it encourages a single module to be used with a standardised name.
- New attribute ExtraSkinModules – similar to ResourceModules but only conditionally registered based on the skin. Modules in ResourceModules are available always and would be what extensions use. ExtraSkinModules is what skins would use to register extra modules and would not be loadable from page view that uses a different skin.
Internally:
- New config wgResourceSkinModules, similar to ResourceModules but with an extra key layer for skin name. E.g. wgResourceSkinModules['timeless']['skins.timeless.foo'] would be a module skins.timeless.foo only loadable in contexts where the skin is timeless.
- The extension processor would add SkinModule entries to wgResourceSkinModules[info.name]["skin"].
- The extension processor would add ExtraSkinModules entries to wgResourceSkinModules[info.name].
This proposal is a minimal alternative to T253582: Let ResourceLoader only register skin modules for the current skin. If that task gains traction, then this task is probably not warranted so as to keep the skin interface simple and easy to use.