Manual:Hooks/ResourceLoaderModifyStartupSourceUrls
Appearance
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.php |
Interface: | ResourceLoaderModifyStartupSourceUrlsHook.php |
For more information about attaching hooks, see Manual:Hooks .
For examples of extensions using this hook, see Category:ResourceLoaderModifyStartupSourceUrls extensions.
Details
[edit]- array &$urls - An array of source name => URL; the URL might be relative.
- MediaWiki\ResourceLoader\Context $context
Usage
[edit]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
- ResourceLoader
$wgResourceModules
- Register modules that can later be loaded on a page$wgResourceModuleSkinStyles
- Register skin-provided stylesheets to add to an existing ResourceLoader module$wgResourceLoaderDebug
- Configure the default debug mode for MediaWiki.- Internal configuration settings:
$wgExtensionAssetsPath
,$wgResourceLoaderMaxage
- ResourceLoaderRegisterModules hook
- Developing with ResourceLoader â Learn how to use ResourceLoader in MediaWiki