Page MenuHomePhabricator

Improve Parsoid's loading of CSS modules using ResourceLoader
Closed, ResolvedPublic

Description

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.

Related Objects

StatusSubtypeAssignedTask
OpenReleaseNone
OpenNone
OpenNone
OpenNone
OpenFeatureNone
OpenNone
ResolvedTchanders
ResolvedTchanders
ResolvedEsanders
DeclinedNone
ResolvedCatrope
ResolvedSbailey
Resolved GWicke
Resolvedssastry
ResolvedNone
ResolvedArlolra
ResolvedEsanders
Resolvedssastry
Resolved AlexMonk-WMF
ResolvedEsanders
DeclinedNone
DeclinedNone
OpenNone
ResolvedArlolra
Resolved marcoil

Event Timeline

marcoil claimed this task.
marcoil raised the priority of this task from to Needs Triage.
marcoil updated the task description. (Show Details)
marcoil added a project: Parsoid.
marcoil added subscribers: marcoil, Legoktm, ssastry and 2 others.

Notes from the offline meeting (with @ssastry, @GWicke, @Legoktm and @Catrope):

The current Parsoid header is only used, right now, for our testing of visual differences and Kiwix (not directly, heavily post-processed). Other users of Parsoid's output (VE, Flow, etc.) strip the header and use the CSS already loaded by the main MW page or, in some cases, load additional CSS from MW. So, the situation is not really bad but we have to take into account that some future use-cases (like mobile apps) may have to load CSS independently of PHP.

Some recommendations:

  • Switch from using en.wikipedia.org/load.php to bits.wikimedia.org/load.php. This should be set as a local setting so independent wikis can still use their own load.php if they want.
  • We could turn off debug=true when calling load.php.

I'll implement these as Parsoid patches. Thanks everyone for your help in this!

gerritbot subscribed.

Change 187591 had a related patch set uploaded (by Marcoil):
T86902: Add new local setting for CSS modules load URI

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

Patch-For-Review

Change 187592 had a related patch set uploaded (by Marcoil):
T86902: Switch debug off for ResourceLoader modules loading

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

Patch-For-Review

Change 187591 merged by jenkins-bot:
T86902: Add new local setting for CSS modules load URI

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

Change 187592 merged by jenkins-bot:
T86902: Switch debug off for ResourceLoader modules loading

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

Marking as closed as the recommendations from the meeting have been merged. However, we should revisit this if/when Parsoid HTML is used directly or if we ever need to load javascript/messages modules.