Wikipedia:User scripts/Guide: Difference between revisions

Content deleted Content added
Text editors: copyedit
mention jQuery before OOjs as more often used
Line 87:
All Wikipedia pages include some built-in [[MediaWiki]] JavaScript code, with variables and functions that can be used in user scripts. Some of them were already mentioned (<code>$()</code>, <code>importScript()</code>, <code>mw.util</code>). This code is generally loaded as [[mw:ResourceLoader/Core modules|ResourceLoader modules]] (some of it preloaded, some loaded on demand) and ends up in properties of these globally available objects:
* <code>mw</code> (<code>mediaWiki</code>) for MediaWiki core,
* <code>OO$</code> (<code>jQuery</code>) for [[mw:OOjsjQuery|OOjsjQuery]],
* <code>$OO</code> (<code>jQuery</code>) for [[mw:jQueryOOjs|jQueryOOjs]].
 
Some commonly accessed properties of <code>mw</code> include <code>mw.config</code>, <code>mw.user.options</code>, <code>mw.util</code>, <code>mw.Title</code>, <code>mw.loader</code>, and <code>mw.hook</code>. <code>OO.ui</code> is the namespace of [[mw:OOUI|OOUI]]. See [[mw:ResourceLoader/Core modules]] for more details.
Line 144:
* Color code JavaScript code
* Quickly insert standard JavaScript keywords and methods ([[code completion]])
** With the help of type definition libraries, you may also get code completion for the [[#Built-in scripts|globally available objects]] of [https://www.npmjs.com/package/types-mediawiki MediaWiki], [https://www.npmjs.com/package/@types/oojsjquery OOjsjQuery], [https://www.npmjs.com/package/@types/oojs-ui OOUIOOjs], and [https://www.npmjs.com/package/@types/jqueryoojs-ui jQueryOOUI].
* Show the list of all functions and quickly jump to any function