Manual:Interface/JavaScript

MediaWiki:Common.js contains JavaScript that will be loaded for all users. This file is loaded for all users, but there are similar files affecting only users of specific skins (see below).

if $wgAllowUserJs is set to true, users can customize the interface for themselves only by creating user subpages with lowercase titles (see below).

Global scripts

 * MediaWiki:Common.js (all skins)
 * MediaWiki:skinname.js (per skin, for example MediaWiki:Vector.js)
 * Special:Gadgets

Personal scripts

 * User:Example user/common.js (all skins - introduced in MW v1.17)
 * User:Example/skinname.js (per skin, for example User:Example/vector.js)

mw.config
For the benefit of easier JavaScript programming, the MediaWiki software exposes a number of configuration variables into an object called mw.config.

Site-wide
Some additional site-wide variables are present only depending on the wiki configuration.

Page-specific
Some additional variables are present only depending on the page namespace, wiki configuration and/or user preferences.

Hooks for extensions

 * ResourceLoaderGetConfigVars: Since MediaWiki 1.17 extensions can add their own site-wide variables through this hook.
 * MakeGlobalVariablesScript: Since MediaWIki 1.14 extensions can add their own variables to the OutputPage. If the variable is not dependant on the page being viewed, the ResourceLoaderGetConfigVars hook should be used instead.