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.

marcoil created this task.Jan 15 2015, 11:12 AM
marcoil updated the task description. (Show Details)
marcoil raised the priority of this task from to Needs Triage.
marcoil claimed this task.
marcoil added a project: Parsoid.
marcoil added subscribers: marcoil, Legoktm, ssastry and 2 others.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJan 15 2015, 11:12 AM
ssastry set Security to None.Jan 15 2015, 3:27 PM
ssastry added subscribers: Jackmcbarn, matmarex.
marcoil triaged this task as Normal priority.Jan 21 2015, 1:08 AM

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 added a subscriber: gerritbot.

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

marcoil closed this task as Resolved.Feb 3 2015, 9:05 AM

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.