Manual:Interface/JavaScript

MediaWiki:Common.js contains JavaScript that will be loaded for all users. Enter "MediaWiki:Common.js" into the search box of your wiki. It will tell you if the page doesn't exist; if so, and you have the necessary, just create it with the code you need to execute. There are similar pages affecting only users of specific (see below).

If  is set to true, users can customize the interface for only themselves by creating and importing personal scripts in certain user subpages.  makes it easier for site admins and users to share JavaScript, see .

This page covers the state and configuration variables available. For the general JavaScript API, see the [https://doc.wikimedia.org/mediawiki-core/master/js/ JSDuck documentation].

Global scripts

 * MediaWiki:Common.js - all skins, but ignored by the mobile website provided by )
 * MediaWiki:skinname.js - per skin, for example MediaWiki:Vector.js
 * - per user group, for example <tvar|1>MediaWiki:Group-sysop.js</>
 * MediaWiki:Mobile.js - specific to the mobile website and provided by <tvar|1></>
 * Special:Gadgets

Personal scripts
They're only available if is set to true.


 * User:Example/common.js - all skins - introduced in MW v1.17
 * User:Example/skinname.js - per skin, for example <tvar|1>User:Example/vector.js</>; always lowercase )
 * User:Example/global.js - per <tvar|1></>, if <tvar|2></> is in use in for this family

To facilitate JavaScript programming, the MediaWiki software exposes a number of configuration values in an object called <tvar|1></>.

These values can be accessed through <tvar|1> </>, documented at 2>Special:MyLanguage/RL/DM#mediaWiki.config</>|ResourceLoader/Core modules.

All pages (user/page-specific)
Related to the user currently viewing the page:

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

Page specific (Wikibase extension)
Some additional informations will be available when the site supports <tvar|1></>:

Hooks for extensions

 * - Since MediaWiki 1.17 extensions can add their own site-wide variables through this hook.
 * - Since MediaWiki 1.14 extensions can add their own variables to the <tvar|1>OutputPage</>. If the variable is not dependent on the page being viewed, use the <tvar|1></> hook instead.