Page MenuHomePhabricator

Load module 'mediawiki.action.view.postEdit' only when needed
Closed, ResolvedPublic8 Story Points

Description

Currently the module 'mediawiki.action.view.postEdit' is loaded on every article views although the module is only needed once directly after an edit and the cookie is set.

Details

Related Gerrit Patches:

Event Timeline

Fomafix created this task.Apr 29 2017, 11:34 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptApr 29 2017, 11:34 AM

Change 351015 had a related patch set uploaded (by Fomafix; owner: Fomafix):
[mediawiki/core@master] Load module 'mediawiki.action.view.postEdit' only when needed

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

Fomafix claimed this task.Apr 29 2017, 7:36 PM

Change 351015 merged by jenkins-bot:
[mediawiki/core@master] Clear postEdit cookie on server-side

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

Krinkle closed this task as Resolved.May 11 2017, 10:09 PM
Fomafix reopened this task as Open.Jun 8 2017, 6:03 PM

The module mediawiki.action.view.postEdit is still loaded on all page views:

> mw.loader.getState( 'mediawiki.action.view.postEdit' )
"ready"

I don't know why.

Fomafix closed this task as Resolved.Jun 9 2017, 6:16 AM

The module mediawiki.action.view.postEdit is loaded by a dependency in other extensions used on the WMF projects.

Krinkle reopened this task as Open.Oct 5 2017, 9:04 PM
Krinkle added a subscriber: Krinkle.

Re-opening. Following optimisation work on the mediawiki.notification module from f2e8cd6dbdfc4, it occurred to me the page I was reading did not produce any notifications. We always recommend using mw.notify() which lazy-loads the module on first use. The reason it was loaded is because:

  1. postEdit.js was changed to depend on mediawiki.notification directly (for its CSS styles) - f8ac9bb2e6a28c0
  2. VisualEditor's ext.visualEditor.desktopArticleTarget.init module was changed to depend on postEdit - 1e04640d02c9

Given postEdit was especially optimised to only be loaded where needed and yet (when loaded) not require further lazy-loading, it probably doesn't make sense to change postEdit.js. It loading mediawiki.notification at the same time is fine.

We should instead update VisualEditor to not require postEdit as part of its on-every-page-view "init init" module. It's only needed after saving an edit. Loading it as part of the earliest "init" module on every page is a bit too much. I'd recommend removing as dependency from the init-init code and instead loading it in one of the following two ways:

  1. Move to the list of modules batch loaded at edit-start time within ve.init.mw.ArticleTargetLoader.js. This would delay editor startup, and actually not work for the second case listed below.
  2. A better optinon: Lazy-load where needed, as part of an existing batch where possible, in the two places it is used:
    • DesktopArticleTarget#saveComplete: Can be loaded as part of the mw.loader.load() batch for the page view. The mw.hook call will naturally be handled once it arrived, no using() promise needed.
    • DesktopArticleTarget.init#uri.query.venotify: This is the handler for after the case where save has to redirect/refresh (e.g. when creating a page or restoring). It can be specifically preloaded here with a one-off mw.loader.load().
Krinkle triaged this task as Normal priority.Oct 5 2017, 9:04 PM
Krinkle moved this task from Inbox to Radar on the Performance-Team board.Oct 5 2017, 9:12 PM
Krinkle edited projects, added Performance-Team (Radar); removed Performance-Team.
Krinkle moved this task from Limbo to Watching on the Performance-Team (Radar) board.
Jdforrester-WMF set the point value for this task to 8.

Change 382614 had a related patch set uploaded (by Jforrester; owner: Jforrester):
[mediawiki/extensions/VisualEditor@master] DesktopArticleTarget.init: Load 'mediawiki.action.view.postEdit' via loader

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

Change 382614 merged by jenkins-bot:
[mediawiki/extensions/VisualEditor@master] DesktopArticleTarget.init: Load 'mediawiki.action.view.postEdit' via loader

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

Deskana closed this task as Resolved.Oct 10 2017, 11:54 AM
Restricted Application added a project: User-Ryasmeen. · View Herald TranscriptOct 10 2017, 11:54 AM