Page MenuHomePhabricator

Use virtual config.json file instead of addJsConfigVars
Closed, ResolvedPublic1 Estimated Story Points

Description

Background

Hooks::onArticleViewHeader() uses $out->addJsConfigVars() to send three config vars to the client. For config vars that don't change from request to request, the best practice is to use a virtual config.json file instead. See https://www.mediawiki.org/wiki/ResourceLoader/Package_files#Generated_content (and also https://www.mediawiki.org/wiki/ResourceLoader/Package_files#Config_files , but you probably can't use that because of the thumblimits thing).

Using the best practice will make the code more readable; will make features easier to revert without caching issues (JS has a much shorter cache life); and is more performant since it doesn't modify HTML.

Requirements

  • Remove the calls to addJsConfigVars from hooks
  • Add the following to packageFile and access config.json from the ifles.
{
					"name": "config.json",
					"config": [
						"ReaderExperimentsApiBaseUri",
						"ReaderExperimentsImageBrowsingExternalWikis"
					]
				},
				{

Event Timeline

Change #1194273 had a related patch set uploaded (by Reeti; author: Reeti):

[mediawiki/extensions/ReaderExperiments@master] ReaderExperiments: Move static client config to virtual package file

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

Claimed this task I’m actively working on a patch.

HSwan-WMF triaged this task as Medium priority.Oct 8 2025, 4:29 PM
HSwan-WMF moved this task from Incoming/Inbox to Ready on the Reader Growth Team board.
HSwan-WMF set the point value for this task to 1.

Change #1194273 had a related patch set uploaded (by Reeti; author: Reeti):

[mediawiki/extensions/ReaderExperiments@master] ReaderExperiments: Remove dynamic package callback and cleanup

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

Jdlrobson-WMF lowered the priority of this task from Medium to Low.Oct 28 2025, 4:46 PM

Change #1194273 abandoned by Reeti:

[mediawiki/extensions/ReaderExperiments@master] ReaderExperiments: Remove dynamic package callback and cleanup

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

Change #1205120 had a related patch set uploaded (by Matthias Mullie; author: Matthias Mullie):

[mediawiki/extensions/ReaderExperiments@master] Expose vars through config file instead of adding to output

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

Change #1205120 merged by jenkins-bot:

[mediawiki/extensions/ReaderExperiments@master] Expose vars through config file instead of adding to output

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

QA

Before: Three config variables were sent to the client and modified the HTML. This included: ReaderExperimentsApiBaseUri, ReaderExperimentsImageBrowsingExternalWikis, and ReaderExperimentsImageBrowsingThumbLimits.

  • Config variables are highlighted within a green box in the screenshot from production wiki
    jsConfigVar_pied-billed_grebe.png (3,074×632 px, 576 KB)

Expected behavior: The config variables are no longer present in the HTML.

Plan