Extension:UseResource

The TemplateScripts extension adds the  tag that allows a JavaScript script to be loaded from the wiki on a per page basis. When used in a template, pages that use the template will have the JS code loaded, this allows for the loading of scripts only used on some pages of the wiki to only be loaded on the pages its used instead of the global MediaWiki:Common.js. Scripts can only be loaded from the MediaWiki namespace to prevent malicious code from being run.

Usage
The extension is used by including  tags on wiki pages to load the script, replacing   with the name of the script.

Scripts are located in the MediaWiki namespace and can only be edited by uses with the  userright as they are the only users allowed to edit pages in the MediaWiki namespace.

The value of the  attribute is the name of the script to load. If not namespace is included, the MediaWiki namespace is assumed. For example, if you had a script located at MediaWiki:Test.js, you could load it using. This will fail if the requested script does not exist, is not located in the MediaWiki namespace, or if it does not have the JavaScript content model.

If the same script is included on a single page multiple times, it is only run once.