Page MenuHomePhabricator

ResourceLoader: consider removing `mw.inspect` function from mediawiki.base
Open, MediumPublic


The mw.inspect function is a part of mediawiki.base and is used as a shortcut to lazy-load the mediawiki.inspect module. I would suggest that this module is not used frequently enough to warrant this loading code being added to everyone's page views:

  • Codesearch reports that the method is only called by the PerformanceInspector extension, as well as referred to in comments suggesting that it can be used for debugging
  • A global search of JavaScript pages (link) revealed only a single mention, and that is in this userscript which appears to be a copy of mediawiki base.

Accordingly, I would suggest removing the lazy-load shortcut, in favor of suggesting that the module be loaded directly and then used

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

The module is lazy loaded when called. The only code that is in the base is the one-line mw.inspect() function to help discover and load the code in question. This feature doesn't exist for the purposes or programmatic access, it exists for use by humans from the browser console, and is considered part of the developer tools.

It was originally part of the mediawiki startup bundle, and was moved to the mediawiki.base module so that it does not download repeatedly and does not delay the module loading process. The mediawiki.base module is strongly cached and loads concurrently to all other modules

I'm open to making the implementation smaller, but the method should remain as part of the stable API we provide to developers to understand and improve site performance.

Krinkle triaged this task as Medium priority.Dec 12 2022, 7:38 PM
Krinkle moved this task from Inbox to Backlog on the MediaWiki-ResourceLoader board.