Template:Install user script/doc: Difference between revisions

Content deleted Content added
Line 24:
 
In conclusion, importScript() is not deprecated, and editors should feel free to use it. It does not need to be systematically replaced by mw.loader.load(), and {{T|iusc}} does not need to be replaced with {{T|lusc}}.
 
== importScript() vs mw.loader.load() ==
{{T|Install user script}} uses importScript(), and {{T|Load user script}} uses mw.loader.load().
 
importScript():
 
* Is less verbose, only needing the string of the the page you're loading.
* Is more restrictive, only allowing the loading of Wikipedia pages in the user or MediaWiki namespaces.
* Can load from other Wikimedia wikis, using a prefix such as "c" for "commons". For example, <code>importScript('c:User:YourName/test.js');</code>
 
mw.loader.load():
 
* Is more verbose, needing a long URL string. Note that the URL string has to be correctly escaped.
* Is less restrictive. Will load any URL from anywhere. So for example is good for loading from a local dev environment such as localhost.
* Can load from other Wikimedia wikis by adjusting the URL.
 
== See also ==