Last week, I asked the right way to inject raw JavaScript so that "mw" and
"jQuery" were defined. I was helpfully pointed to
ResourceLoader::makeInlineScript(), which wraps the JS in the appropriate magic:
https://lists.wikimedia.org/pipermail/wikitech-l/2015-December/084408.html
Now, what is the right way to include a remote JavaScript file? If I simply use
OutputPage::addScript() like this:
$myOutputPage->addScript('<script
src="http://remote.com/myfile.js"></script>')
it fails because the remote JavaScript file references the "jQuery" object like
this:
function ($) {
//... code here
}(jQuery));
I get "ReferenceError: jQuery is not defined" on the last line. I guess the
remote script is getting evaluated before ResourceLoader brings in jquery.js...?
Thanks very much for any advice.
DanB