Global JavaScript not loading on some sites
Closed, ResolvedPublic

Description

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

Details

Reference
bz34482
bzimport set Reference to bz34482.
bzimport added a subscriber: Unknown Object (MLST).
Reedy added a comment.Feb 17 2012, 9:16 PM

Do you get any errors?

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

alert("hi!");

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.

Add Comment