Manual:Hooks/ResourceLoaderModifyStartupSourceUrls
ResourceLoaderModifyEmbeddedSourceUrls | |
---|---|
Available from version 1.43.0 (Gerrit change 1076243) 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 onResourceLoaderModifyEmbeddedSourceUrls( array &$urls ) { ... }
|
Attach hook: | In extension.json:
{
"Hooks": {
"ResourceLoaderModifyEmbeddedSourceUrls": "MediaWiki\\Extension\\MyExtension\\Hooks::onResourceLoaderModifyEmbeddedSourceUrls"
}
}
|
Called from: | File(s): ResourceLoader/ImageModule.phpCategory:MediaWiki hooks included in ImageModule.php#ResourceLoaderModifyEmbeddedSourceUrls, ResourceLoader/StartUpModule.phpCategory:MediaWiki hooks included in StartUpModule.php#ResourceLoaderModifyEmbeddedSourceUrls |
Interface: | ResourceLoaderModifyEmbeddedSourceUrlsHook.php |
For more information about attaching hooks, see Manual:Hooks .
For examples of extensions using this hook, see Category:ResourceLoaderModifyEmbeddedSourceUrls extensions.
Details
- array &$urls - An array of source name => URL; the URL might be relative.
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
- 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