Page MenuHomePhabricator

Reduce number of modules registered by MassMessage
Open, Needs TriagePublic

Description

For context and rationale, see:

$ cat extension.json | jq '.ResourceModules | keys'
[
  "ext.MassMessage.autocomplete",
  "ext.MassMessage.content",
  "ext.MassMessage.content.js",
  "ext.MassMessage.content.noedit",
  "ext.MassMessage.content.nojs",
  "ext.MassMessage.create",
  "ext.MassMessage.edit",
  "ext.MassMessage.special",
  "ext.MassMessage.special.js"
]
Starting point
  1. ext.MassMessage.autocomplete (uses jquery.ui)
  2. ext.MassMessage.content (styles-only)
  3. ext.MassMessage.content.js (uses jquery.ui, and ext.MassMessage.autocomplete)
  4. ext.MassMessage.content.noedit (styles-only)
  5. ext.MassMessage.content.nojs (styles-only)
  6. ext.MassMessage.create (uses oojs-ui, and jquery.ui and ext.MassMessage.autocomplete)
  7. ext.MassMessage.edit (uses oojs-ui)
  8. ext.MassMessage.special (styles-only)
  9. ext.MassMessage.special.js (uses jquery.ui, and ext.MassMessage.autocomplete)
To do
  • Identify which distinct end-user scenarios MassMessage has resources for.
  • Determine how large the total payload from MassMessage for each of these scenarios is.
  • Determine which distinct deliverable bundles we need (possibly sharing one for several distinct use cases if overlap is significant and/or if overall size is small, e.g. under 3KB).
  • Combine modules into larger bundles and give name them accordingly where needed

Event Timeline

Krinkle created this task.Oct 19 2019, 8:23 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptOct 19 2019, 8:23 PM
Krinkle added a project: Editing-team.
Krinkle added a subscriber: Legoktm.

Triaging based on mw:Maintainers.

Krinkle updated the task description. (Show Details)Oct 19 2019, 8:27 PM

onBeforePageDisplay hook handler is the only user of 4 distinct modules:

public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) {
	$title = $out->getTitle();
	if ( $title->exists() && $title->hasContentModel( 'MassMessageListContent' ) ) {
		$out->addModuleStyles( 'ext.MassMessage.content.nojs' );
		$permManager = MediaWikiServices::getInstance()->getPermissionManager();
		if ( $out->getRevisionId() === $title->getLatestRevId()
			&& $permManager->quickUserCan( 'edit', $out->getUser(), $title )
		) {
			$out->addModuleStyles( 'ext.MassMessage.content' );
			$out->addModules( 'ext.MassMessage.content.js' );
		} else {
			$out->addModuleStyles( 'ext.MassMessage.content.noedit' );
		}
	}
}

ext.MassMessage.content.nojs is defined as a single file, ext.MassMessage.content.nojs.css, which can simply be included in both the ext.MassMessage.content and ext.MassMessage.content.noedit modules rather than registered separately

Change 599412 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/extensions/MassMessage@master] Remove ext.MassMessage.content.nojs module

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

The ext.MassMessage.autocomplete module is fairly simply, and is only used as a dependency by other modules that can simply include the underlying script themselves

Change 599414 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/extensions/MassMessage@master] Remove ext.MassMessage.autocomplete module

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

Change 599412 merged by jenkins-bot:
[mediawiki/extensions/MassMessage@master] Remove ext.MassMessage.content.nojs module

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

DannyS712 moved this task from Unsorted to In progress on the User-DannyS712 board.

@DannyS712 As a possible next change, perhaps the three styles-only modules can be combined if they are not very large?

Change 599414 merged by jenkins-bot:
[mediawiki/extensions/MassMessage@master] Remove ext.MassMessage.autocomplete module

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

@DannyS712 As a possible next change, perhaps the three styles-only modules can be combined if they are not very large?

Sure, though there will be a patch or two in the middle to help me wrap my head around the modules

Change 607890 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/extensions/MassMessage@master] ext.MassMessage.content.noedit module: Don't include the nojs.css

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

Change 607892 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/extensions/MassMessage@master] Merge ext.MassMessage.content.nojs.css into content.css

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

Change 607890 merged by jenkins-bot:
[mediawiki/extensions/MassMessage@master] ext.MassMessage.content.noedit: Remove redundant nojs.css

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

Change 608474 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/extensions/MassMessage@master] Convert ext.MassMessage.autocomplete.js to packageFiles

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/MassMessage/ /608474

Change 607892 merged by jenkins-bot:
[mediawiki/extensions/MassMessage@master] Merge style-only modules into ext.MassMessage.styles

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/MassMessage/ /607892