Manual:$wgResourceModules

Examples
Here is a basic example for usage in an extension.

You would put this in your   file.

You would put this in the main php file like  .

The above example will create a module called ' ', which includes the script  , the style  , and so on.

It also ensures that two modules ' ' and ' ' are available before execution.

Details
By default modules are registered as an instance of ResourceLoaderFileModule.

You find the according code in  .

Here is the documentation:


 * class
 * Alternate subclass of ResourceLoader (rather than default ResourceLoaderFileModule). If this is used, some of the other properties may not apply, and you can specify your own arguments.  Since MediaWiki 1.30, it may now specify a callback function as an alternative to a plain class name, using the   key in the module description array.  This allows dependency injection to be used for ResourceLoader modules.
 * Class name of alternate subclass


 * debugScripts
 * Scripts to include in debug contexts.
 * File path string or array of file path strings.


 * dependencies
 * Modules which must be loaded before this module.
 * Module name string or array of module name strings.


 * deprecated
 * Whether the module is deprecated and usage is discouraged.
 * Either a boolean, or a string or an object with key message can be used to customise deprecation message.


 * group
 * Group which this module should be loaded together with
 * Group name string.


 * languageScripts
 * Scripts to include in specific language contexts.
 * Array keyed by language code containing file path string or array of file path strings.


 * loaderScripts
 * Scripts to include in the startup module.
 * File path string or array of file path strings.


 * localBasePath
 * Base path to prepend to all local paths in $options. Defaults to <tvar|IP></>.
 * Base path


 * messages
 * Messages to always load
 * Array of message key strings.
 *  See 1>Special:MyLanguage/ResourceLoader/Features#Groups</>|detailed documentation before using this. 


 * noflip
 * Whether to skip CSSJanus LTR-to-RTL flipping for this module. Recommended for styles imported from libraries that already properly handle their RTL styles.  Default is false, meaning CSSJanus will be applied on RTL-mode output.
 * Boolean.


 * packageFiles
 * Package files that can be required.
 * String or array of package file.


 * position
 * Position on the page to load this module at.
 * String. Can be either "top" or "bottom".


 * remoteBasePath
 * Base path to prepend to all remote paths in $options. Defaults to <tvar|ScriptPath></>.
 * Base path


 * remoteExtPath
 * Equivalent of remoteBasePath, but relative to <tvar|ExtensionAssetPath></>.
 * Base path


 * scripts
 * Scripts to always include.
 * File path string or array of file path strings.


 * skinScripts
 * Scripts to include in specific skin contexts.
 * Array keyed by skin name containing file path string or array of file path strings.


 * skinStyles
 * Styles to include in specific skin contexts. (mapping of skin name to style(s))
 * Array keyed by skin name containing file path string or array of file path strings.


 * skipFunction
 * Function that returns true when the module should be skipped. Intended for when the module provides a polyfill that is not required in modern browsers
 * Filename of a JavaScript file with a top-level return (it should not be wrapped in a function)


 * styles
 * Styles to always include in the module.
 * File path string, or list of file path strings. The included file can be automatically wrapped in a  query by specifying the file path as the key in an object, with the value specifying the media query. Examples below:


 * targets
 * ResourceLoader target the module can run on.
 * String or array of targets.


 * templates
 * Templates to be loaded for client-side usage.
 * Object or array of templates.

Loading module
See also <tvar|1></>: