Page MenuHomePhabricator

Drastically reduce the number of ResourceLoader modules that CX creates
Closed, ResolvedPublic

Description

As of 7 May 2018 in production, ContentTranslation's own 131 RL modules result in 6573 bytes being shipped on every page view for every reader. That's 3TiB a day of extra load on readers. There's even more if you count the ULS stuff CX uses, but I'll leave that for now.

Ideally CX would only ship itself in two modules – a skinny 'loader' and the full-fat rest of the product – but any reduction would be worthwhile.

Event Timeline

Jdforrester-WMF created this task.
Jdforrester-WMF added a subscriber: Krinkle.
Jdforrester-WMF raised the priority of this task from Medium to Needs Triage.Sep 6 2018, 5:23 PM
Pginer-WMF triaged this task as Medium priority.Sep 7 2018, 11:23 AM
Pginer-WMF moved this task from Needs Triage to CX2 on the ContentTranslation board.

Change 485795 had a related patch set uploaded (by Santhosh; owner: Santhosh):
[mediawiki/extensions/ContentTranslation@master] Merge RL module ext.cx.contributions.init and ext.cx.contributions

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

Change 485796 had a related patch set uploaded (by Santhosh; owner: Santhosh):
[mediawiki/extensions/ContentTranslation@master] Merge RL module mw.cx.VersionSwitcher in ext.cx.dashboard

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

Change 485797 had a related patch set uploaded (by Santhosh; owner: Santhosh):
[mediawiki/extensions/ContentTranslation@master] Merge RL modules ext.cx.editor and ext.cx.translation

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

Change 485798 had a related patch set uploaded (by Santhosh; owner: Santhosh):
[mediawiki/extensions/ContentTranslation@master] Merge RL modules ext.cx.pageselector and ext.cx.tools.link

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

Change 486008 had a related patch set uploaded (by Santhosh; owner: Santhosh):
[mediawiki/extensions/ContentTranslation@master] Merge RL modules into mw.cx.MwApiRequestManager and mw.cx.init.Translation

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

Change 486009 had a related patch set uploaded (by Santhosh; owner: Santhosh):
[mediawiki/extensions/ContentTranslation@master] Remove unused RL module mw.cx.ui.mixin and file

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

Change 486015 had a related patch set uploaded (by Santhosh; owner: Santhosh):
[mediawiki/extensions/ContentTranslation@master] Merge all columns related UI modules into mw.cx.ui.TranslationView

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

Change 486009 merged by jenkins-bot:
[mediawiki/extensions/ContentTranslation@master] Remove unused RL module mw.cx.ui.mixin and file

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

Change 485797 merged by jenkins-bot:
[mediawiki/extensions/ContentTranslation@master] Merge RL modules ext.cx.editor and ext.cx.translation

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

Change 485798 merged by jenkins-bot:
[mediawiki/extensions/ContentTranslation@master] Merge RL modules ext.cx.pageselector and ext.cx.tools.link

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

Change 485795 merged by jenkins-bot:
[mediawiki/extensions/ContentTranslation@master] Merge RL module ext.cx.contributions.init and ext.cx.contributions

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

Change 485796 merged by jenkins-bot:
[mediawiki/extensions/ContentTranslation@master] Merge RL module mw.cx.VersionSwitcher in ext.cx.dashboard

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

Change 486015 merged by jenkins-bot:
[mediawiki/extensions/ContentTranslation@master] Merge all columns related UI modules into mw.cx.ui.TranslationView

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

Change 486008 merged by jenkins-bot:
[mediawiki/extensions/ContentTranslation@master] Merge RL modules into mw.cx.MwApiRequestManager and mw.cx.init.Translation

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

On 1st April 2019, we have 111 RL modules in CX

Some canidate modules to remove:

  1. mw.cx.dm.TranslationIssue - used only by mw.cx.init.Translation and lazy loaded in it. It does not look a candidate for lazy loading now. If we can merge it with mw.cx.init.translation, that should reduce on RL module. It has only a single script file
  2. mw.cx.ui.Columns.legacy and mw.cx.ui.SourceColumn.legazy etc- all for cx1. cx1 is going to be there for another year. So clubbing all of them to a single module is a good idea. Just like we did for cx2
  3. mw.cx.ui.CategoryTagItemWidget, mw.cx.ui.CategoryInputWidget and mw.cx.ui.CategoryMultiselectWidget can be merged
  1. mw.cx.dm.TranslationIssue - used only by mw.cx.init.Translation and lazy loaded in it. It does not look a candidate for lazy loading now. If we can merge it with mw.cx.init.Translation, that should reduce on RL module. It has only a single script file

mw.cx.dm.TranslationIssue is also lazy loaded in ve.dm.CXLintableNode. Also, mw.cx.init.Translation.prototype.checkForTranslationChanges is always called, but the early return is hit more times than not, so we should not merge this module.

  1. mw.cx.ui.CategoryTagItemWidget, mw.cx.ui.CategoryInputWidget and mw.cx.ui.CategoryMultiselectWidget can be merged

This can definitely be done. I'll submit a patch.

Change 500625 had a related patch set uploaded (by Petar.petkovic; owner: Petar.petkovic):
[mediawiki/extensions/ContentTranslation@master] Merge category widget modules

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

Change 500625 merged by KartikMistry:
[mediawiki/extensions/ContentTranslation@master] Merge category widget modules

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

As of today we have 106 RL modules. So as part of this ticket we reduced 25 RL modules. I am moving this ticket to done, but we need to actively look for more opportunities to reduce RL modules as we refactor or enhance featues.

CX1 co-existing with CX2 is the main reason behind many modules. CX1 code will be removed by end of this year and expecting about 50& reduction about RL modules.

CX1 code will be removed by end of this year

More likely by end of the next year, given CX1 was disabled for new translations just last month and purge scripts cleans drafts older than 420 days.