Manual:Hooks/ResourceLoaderModifyStartupSourceUrls

Category:MediaWiki hooks#ResourceLoaderModifyStartupSourceUrls Category:Hooks added in MediaWiki 1.43.0#ResourceLoaderModifyStartupSourceUrls
ResourceLoaderModifyStartupSourceUrls
Available from version 1.43.0
Allows modifying source URLs (i.e. URLs to load.php) before they get embedded in the JS generated for the startup module.
Define function:
public static function onResourceLoaderModifyStartupSourceUrls( array &$urls, MediaWiki\ResourceLoader\Context $context ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"ResourceLoaderModifyStartupSourceUrls": "MediaWiki\\Extension\\MyExtension\\Hooks::onResourceLoaderModifyStartupSourceUrls"
	}
}
Called from: File(s): includes/ResourceLoader/StartUpModule.phpCategory:MediaWiki hooks included in StartUpModule.php#ResourceLoaderModifyStartupSourceUrls
Interface: ResourceLoaderModifyStartupSourceUrlsHook.php

For more information about attaching hooks, see Manual:Hooks .
For examples of extensions using this hook, see Category:ResourceLoaderModifyStartupSourceUrls extensions.

Details

  • array &$urls - An array of source name => URL; the URL might be relative.
  • MediaWiki\ResourceLoader\Context $context

Usage

The hook lets you modify ResourceLoader source URLs (i.e. URLs to load.php, see ResourceLoader::getSources) before they get embedded in the JS generated for the startup module.

The hook must not add or remove sources, and calling the new URL should have a roughly similar outcome to calling the old URL. It is mainly intended to preserve URL modifications that might affect the code generated for the modules (e.g. when load.php?modules=startup is called on the mobile site, it should generate source URLs which also use the mobile site).

See also

Category:Hooks added in MediaWiki 1.43.0 Category:MediaWiki hooks Category:MediaWiki hooks included in StartUpModule.php