legacy importScript* had something like this. I think we should implement it in mw.loader.load as well.
(ie. keep an array of loaded urls by type, and check if inArray)
Version: 1.18.x
Severity: enhancement
legacy importScript* had something like this. I think we should implement it in mw.loader.load as well.
(ie. keep an array of loaded urls by type, and check if inArray)
Version: 1.18.x
Severity: enhancement
importScript does not pay attention to module names, which causes this issue. If you NEVER use importScript* to load something that is available through mediaWiki.loader.load then you will be fine.
I ran the following line from the console on a fresh logged out load of translatewiki.net (10 times):
mw.loader.load('http://toolserver.org/~krinkle/main.css', 'text/css')
10 <link> elements were appended to the <head>
With legacy importScript('Namespace:Title') this tracking object and "preventing doubles" was a easy solution for wikis to be loading scripts from multiple places and making sure libraries and common scripts are only loaded once (sort of a dependancy stack on top of scripts. They listed the depending scripts on top inside importScript()).
Such as: Many scripts/gadgets on Commons have importScript('MD5.js');
For wiki-pages this is useful, but for URLs this sometimes introduced bugs, such as:
I suggest WONTFIXing this. The dependancy tree and prevention of double-loading will be taken care of by Gadgets.
Although there are a few ways to not including the same twice, here's an example for the MD5.js library.
Per discussion during Hackathon in Berlin, marking as WONTFIX.
Whenever people use importScript's non-double loading as dependancy, should use gadgets and add those as dependancies.
Primary reason being that importScriptURL (and now mw.loader.load) is being used (as documented) to load javascript stuff with callbacks. Including but not limited to periodic requests (ie. polling the API). If we would filter out urls already loaded then that would end up really weird.