Page MenuHomePhabricator

Support loading legacy "site" and "user" modules with mw.loader
Closed, ResolvedPublic

Description

The site and user modules are currently loaded with <script> tags that are injected into the HTML from the PHP side. This is apparently done because they need to be loaded with only=scripts (so they're not wrapped in a closure) and need to be loaded last, after anything else. These things are a bit tricky but not impossible to support in the client-side loader, and loading them from the client side will allow us to timestamp the site module (which currently isn't timestamped because anons get it as well), improving caching efficiency by caching it for 30 days instead of 5 minutes. The user module is already timestamped by PHP, which is OK because logged-in users bypass Squid.

We can't combine the site module with any regular modules due to these requirements. We also can't combine the site and user modules in one request because that would cause insane cache fragmentation.

Event Timeline

bzimport raised the priority of this task from to High.Nov 21 2014, 11:50 PM
bzimport set Reference to bz30358.
bzimport added a subscriber: Unknown Object (MLST).

We can already make them load separately afaik by putting them in different groups with the group property of the ResourceLoaderModule.

Why is only=script/no-wrapper needed though ?

Loaded 'after anything else' is a bit tricky right now. It assumes that everything before (both top/bottom queue) has loaded before that <script> tag and was synchronous, we already know that isn't the case. Some kind of über dependency ?

I'd say let it only depend on the default core and legacy module(s), and recommend stuff that has other dependencies to be put in gadgets after MediaWiki 1.19 (which will have the 'default' and 'hidden' property and support for dependencies).

Adding 1.20 blocker. If possible sooner, but not after 1.20 imho.

(In reply to comment #1)

MediaWiki 1.19 (which will have the 'default' and 'hidden' property and support
for dependencies).

Is this "hidden" property documented anywhere? I found it in use on commons[1], but I'm not sure how it works.

[1] [[commons:MediaWiki_talk:Gadgets-definition#Hidden_gadgets.3F]]

Replied there, at comment 3's [1].

(In reply to comment #0)

[..] This is apparently done because they
need to be loaded with only=scripts (so they're not wrapped in a closure) and
need to be loaded last, after anything else. [..]

I think we can start removing support for implied globals in 1.20 for user-generated content in site/user scripts. We already did that in 1.17 for core, extensions. And Gadgets 2.0 will do it for gadgets.

(In reply to comment #0)

We can't combine the site module with any regular modules.

This would be redundant if we drop the above 2 requirements. We can still put them in a separate group to avoid cache fragmentation though.

(In reply to comment #5)

I think we can start removing support for implied globals in 1.20 for

1.21 now. Any progress on this (and Gadgets 2.0)?

(In reply to comment #6)

(In reply to comment #5)

I think we can start removing support for implied globals in 1.20 for

1.21 now.

That is bug 33837.

Krinkle renamed this task from Make client-side loader load site and user modules to Support loading legacy "site" and "user" modules with mw.loader.Nov 25 2014, 8:56 PM
Krinkle updated the task description. (Show Details)
Krinkle removed a project: Future-Release.
Krinkle set Security to None.
Krinkle removed a subscriber: Unknown Object (MLST).
Krinkle lowered the priority of this task from High to Medium.Apr 10 2015, 5:29 PM

Change 221739 had a related patch set uploaded (by Krinkle):
resourceloader: Implement support for 'site' into mw.loader

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

Change 221739 merged by jenkins-bot:
resourceloader: Implement support for 'site' into mw.loader

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

Change 227912 had a related patch set uploaded (by Krinkle):
[WIP] resourceloader: Ensure 'user' loads after 'site' (asynchronously)

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

Change 227912 merged by jenkins-bot:
resourceloader: Ensure 'user' loads after 'site' (asynchronously)

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

Krinkle claimed this task.
Krinkle moved this task from Accepted Enhancement to Assigned on the MediaWiki-ResourceLoader board.
Krinkle removed a project: Patch-For-Review.
Krinkle removed a subscriber: gerritbot.