See https://www.mediawiki.org/wiki/ResourceLoader/Migration_guide_%28users%29#mw...
On Fri, Jan 8, 2016 at 1:53 PM, Daniel Barrett danb@cimpress.com wrote:
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
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l