Global JavaScript not loading on some sites
Closed, ResolvedPublic


My global javascript at [[m:User:Hazard-SJ/global.js]] Is only loading on some sites, like [[en:]] and [[commons:]], but not sites like [[simple:]], [[meta:]], and [[testwiki:]] which have been updated to 1.19wmf1.

Version: unspecified
Severity: normal

bzimport added a project: MediaWiki-JavaScript.Via ConduitNov 22 2014, 12:09 AM
bzimport added a subscriber: Unknown Object (MLST).
bzimport set Reference to bz34482.
Hazard-SJ created this task.Via LegacyFeb 17 2012, 9:11 PM
Reedy added a comment.Via ConduitFeb 17 2012, 9:16 PM

Do you get any errors?

MarkAHershberger added a comment.Via ConduitFeb 18 2012, 2:26 AM

I can load and execute a global.js from meta with just:


I suspect there are some Resource Loader problems in your code.

These will need to be fixed, or your code will probably stop working. I suspect the problem is with this function:

function importAnyScript(lang,family,script) {

document.write('<script type="text/javascript" src="' + 'http://'

		+ lang + '.'
		+ family + '.org/w/index.php?title='
		+ script + '&action=raw&ctype=text/javascript"></script>');

You probably want to replace that with:

function importAnyScript(lang,family,script) {

mw.loader.load('//' + lang + '.' + family

		+ '.org/w/index.php?title='
		+ script + '&action=raw&ctype=text/javascript');

In fact, when I copied your global.js, and replaced your importAnyScript() function with my version, it worked.

Hazard-SJ added a comment.Via ConduitFeb 22 2012, 3:33 AM


Add Comment