To load the necessary CSS modules into a page, the current code in Parsoid follows these steps:
* When asking for an extension output using the MW API action=parse, it also requests which modules are used.
* Using a set of hard-coded modules and the style modules discovered in the previous step, an URL to load.php is generated (in mediawiki.DOMPostProcessor.js:336–).
* This link is included as a stylesheet link in the generated HTML's <head>.
While discussing options to add loading the new Cite CSS (see T86782) with @Legoktm, it became clear this isn't optimal:
* It doesn't work for parser functions, only for modules added by extensions (because the API doesn't provide the modules used in action=expandtemplates, see task T69540).
* It uses a hard-coded skin (vector).
* It only loads style modules (are javascript and messages modules necessary?).
* Cache / performance issues? (Also, the current code uses debug mode, which should be changed).
Let's use this task to discuss how we can improve the current situation.