Page MenuHomePhabricator

Skip mw.loader.implement() boiler plate for no-op user.options
Closed, ResolvedPublic

Description

In 2014, @ori optimised the way user options are loaded. They were already embedded in page views, but were somewhat wasteful because most options are set to their default values (and in case of logged-out users, all options are the defaults) and these are re-distributed on every page view.

Commit 1c17347580 changed this by splitting the options module in user.options and user.defaults. Where user.options depends on user.defaults and the latter is not embedded, but requested on-demand and highly cacheable client-side.

The result was a significant decrease in HTML payload size by omitting the default options from the response. Currently looks like this:

mw.loader.state({
 ..
 "user.options": "loading",
  ..
});

..


mw.loader.implement("user.options@0bhc5ha",function($,jQuery,require,module){mw.user.options.set([]);})

In 2016, commits 80e5b160, a464d1d41d6 (T92459, T87871) and related ones introduced tracking of initial module state server-side. This is already used to skip requests for user and site wiki modules that are known to be "empty", as well as to initialise the state of style modules to "ready".

We can leverage this to omit mw.loader.implement() and options.set([]); entirely by default and just consider its state to be ready.

Event Timeline

Krinkle lowered the priority of this task from High to Normal.Sep 18 2017, 5:48 PM
Krinkle created this task.
Krinkle moved this task from Inbox to Accepted Enhancement on the MediaWiki-ResourceLoader board.
Krinkle moved this task from Inbox to Doing on the Performance-Team board.

Change 378748 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/core@master] resourceloader: Support isKnownEmpty for general modules

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

Change 378749 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/core@master] resourceloader: Implement isKnownEmpty for user.options module

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

Jdforrester-WMF closed this task as Resolved.Sep 25 2017, 3:29 PM
Jdforrester-WMF removed a project: Patch-For-Review.

Change 378748 merged by jenkins-bot:
[mediawiki/core@master] resourceloader: Support isKnownEmpty for general modules

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

Change 378749 merged by jenkins-bot:
[mediawiki/core@master] resourceloader: Implement isKnownEmpty for user.options module

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

Change 530119 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/core@master] resourceloader: Avoid isKnownEmpty call for regular (non-embed) modules

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

Change 530119 merged by jenkins-bot:
[mediawiki/core@master] resourceloader: Avoid isKnownEmpty call for regular (non-embed) modules

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