Page MenuHomePhabricator

Avoid jquery.accessKeyLabel computation in addPortletLink() when possible
Closed, ResolvedPublic


This is a utility that primarily exists for use by gadgets and user scripts. There aren't any prominent uses of it in source code we deploy from Git, but it's a utility virtually all wikis use in one way or another. Especially logged-in users will likely have a number of (default or opt-in) gadgets enabled that use it during page load.

I noticed this myself and found it has quite a bit of overhead, most of it coming from a rather expensive function call that ends up doing... nothing.

The overhead comes from the use of mw.Message.parser in jquery.accessKeyLabel.

Screen Shot 2018-08-17 at 18.17.43.png (768×1 px, 154 KB)

It is used to compute the string for square brackets, which is localisable. That in turns is used to build a regular expression, to match the generic accesskey labe, e.g. [x] in Some label [x], which it would then replace with something platform specific like [ctrl-option-x].

However, quite often addPortetLink is used without setting an access key. In those cases, this part won't exist in the title and won't need to be added or replaced.

Event Timeline

Krinkle triaged this task as High priority.Aug 17 2018, 5:20 PM
Krinkle created this task.

Change 453439 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/core@master] mediawiki.util: Only call $.fn.updateTooltipAccessKeys if accesskey is set

Change 453439 merged by jenkins-bot:
[mediawiki/core@master] mediawiki.util: Only call $.fn.updateTooltipAccessKeys if accesskey is set