<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://70.231.62.181/index.php?action=history&amp;feed=atom&amp;title=Template%3ALoad_user_script%2Fdoc</id>
	<title>Template:Load user script/doc - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://70.231.62.181/index.php?action=history&amp;feed=atom&amp;title=Template%3ALoad_user_script%2Fdoc"/>
	<link rel="alternate" type="text/html" href="http://70.231.62.181/index.php?title=Template:Load_user_script/doc&amp;action=history"/>
	<updated>2026-04-23T06:39:15Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>http://70.231.62.181/index.php?title=Template:Load_user_script/doc&amp;diff=19998339&amp;oldid=prev</id>
		<title>imported&gt;Oshwah: /* importScript() vs mw.loader.load() */ Improving to make complete sentences.</title>
		<link rel="alternate" type="text/html" href="http://70.231.62.181/index.php?title=Template:Load_user_script/doc&amp;diff=19998339&amp;oldid=prev"/>
		<updated>2025-09-15T20:56:47Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;importScript() vs mw.loader.load(): &lt;/span&gt; Improving to make complete sentences.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Documentation subpage}}{{template shortcuts|lusc}}&lt;br /&gt;
{{Subst only}}&amp;lt;!-- Categories go at the bottom of this page and interwikis go in Wikidata. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This template is used to install [[WP:US|user scripts]] that reside on the English Wikipedia. It is to be used primarily on [[Special:MyPage/common.js]] or [[Special:MyPage/skin.js]]. It adds the necessary &amp;lt;code&amp;gt;mw.loader.load&amp;lt;/code&amp;gt; line along with a [[WP:Backlink|backlink]].&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
In order to install a user script for your Wikipedia account, add the following line to [[Special:MyPage/common.js]] or [[Special:MyPage/skin.js]]: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{subst:lusc|script_path}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
*Replace &amp;lt;code&amp;gt;script_path&amp;lt;/code&amp;gt; with the full .js page name of the user script to be installed.&lt;br /&gt;
*The template &amp;#039;&amp;#039;&amp;#039;must&amp;#039;&amp;#039;&amp;#039; be [[WP:SUBST|substituted]] (&amp;lt;code&amp;gt;subst:&amp;lt;/code&amp;gt;), or else it won&amp;#039;t work.&lt;br /&gt;
*[[WP:BYPASS|Bypass your cache]] after saving the page.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{subst:lusc|User:Example/script.js}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
*&amp;#039;&amp;#039;&amp;#039;Produces:&amp;#039;&amp;#039;&amp;#039; &amp;lt;code&amp;gt;mw.loader.load( &amp;#039;{{localurl:User:Example/script.js|action=raw&amp;amp;ctype=text/javascript}}&amp;#039; ); // Backlink: &amp;lt;nowiki&amp;gt;[[User:Example/script.js]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{subst:lusc|User:Example/script.js|User:Example/script}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
*&amp;#039;&amp;#039;&amp;#039;Produces:&amp;#039;&amp;#039;&amp;#039; &amp;lt;code&amp;gt;mw.loader.load( &amp;#039;{{localurl:User:Example/script.js|action=raw&amp;amp;ctype=text/javascript}}&amp;#039; ); // Backlink: &amp;lt;nowiki&amp;gt;[[User:Example/script]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== importScript() vs mw.loader.load() ==&lt;br /&gt;
{{T|Install user script}} uses importScript(), and {{T|Load user script}} uses mw.loader.load().&lt;br /&gt;
&lt;br /&gt;
importScript():&lt;br /&gt;
&lt;br /&gt;
* Is less verbose, only needing the string of the page you&amp;#039;re loading.&lt;br /&gt;
* Is more restrictive, only allowing the loading of Wikipedia pages in the user or MediaWiki namespaces.&lt;br /&gt;
* Can load from other Wikimedia wikis, using a prefix such as &amp;quot;c&amp;quot; for &amp;quot;commons&amp;quot;. For example, &amp;lt;code&amp;gt;importScript(&amp;#039;c:User:YourName/test.js&amp;#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;#039;&amp;#039;&amp;#039;However&amp;#039;&amp;#039;&amp;#039;, this usage is not recommended as it involves an extra round trip. mw.loader.load is faster for cross-wiki loads.&lt;br /&gt;
* Makes your common.js file more readable, since it is less verbose.&lt;br /&gt;
&lt;br /&gt;
mw.loader.load():&lt;br /&gt;
&lt;br /&gt;
* Is more verbose, needing a long URL string. Note that the URL string has to be correctly escaped.&lt;br /&gt;
* Is less restrictive, allowing you to load any URL from anywhere. For example: it is good for loading from a local dev environment such as localhost.&lt;br /&gt;
* Can load from other Wikimedia wikis by adjusting the URL.&lt;br /&gt;
* Makes your common.js file less readable, since it is more verbose.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* {{tl|Install user script}} ({{tl|iusc}}) – Version of this script that uses the &amp;lt;code&amp;gt;importScript()&amp;lt;/code&amp;gt; method.&lt;br /&gt;
* {{tl|Load user stylesheet}}&lt;br /&gt;
{{Wikipedia:User scripts/Navbox}}&lt;br /&gt;
&amp;lt;includeonly&amp;gt;{{Sandbox other||&lt;br /&gt;
[[Category:Wikipedia JavaScript templates]]&lt;br /&gt;
[[Category:Wikipedia scripts|*]]&lt;br /&gt;
[[Category:Wikipedia user script templates]]&lt;br /&gt;
}}&amp;lt;/includeonly&amp;gt;&lt;/div&gt;</summary>
		<author><name>imported&gt;Oshwah</name></author>
	</entry>
</feed>