Last modified: 2011-05-16 12:14:58 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T28814, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 26814 - mw.loader.load for external script should not include the same twice
mw.loader.load for external script should not include the same twice
Status: RESOLVED WONTFIX
Product: MediaWiki
Classification: Unclassified
ResourceLoader (Other open bugs)
1.18.x
All All
: Normal enhancement (vote)
: ---
Assigned To: Trevor Parscal
:
: 29001 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-01-20 09:50 UTC by Krinkle
Modified: 2011-05-16 12:14 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Krinkle 2011-01-20 09:50:43 UTC
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)
Comment 1 Trevor Parscal 2011-01-20 17:44:18 UTC
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.
Comment 2 Krinkle 2011-01-21 01:55:42 UTC
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>
Comment 3 Krinkle 2011-05-04 20:44:29 UTC
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:

* Dynamic content from static urls (ie. polling the recentchanges API, later requests should not be ignored)
* Synchronous/on-the-fly resources that are order dependant will function wrong if loaded (also) early.
* CSS may cascade the wrong way (rare though, likely result of bad practices)

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.
* It would be defined as a (hidden?) resource-loader gadget.
* For other gadgets: Remove importScript('MD5.js') and add [dependancies:MD5] to the definition instead.
* For user scripts: Replace importScript('MD5.js') with mw.loader.using( 'ext.gadget.MD5', MyScript.initFunction );
Comment 4 Krinkle 2011-05-14 15:53:24 UTC
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.
Comment 5 Roan Kattouw 2011-05-16 12:14:58 UTC
*** Bug 29001 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links