Fair point. What is the ideal way to code on-module-ready in user scripts?
On Sat, May 20, 2017 at 5:34 PM, Brion Vibber bvibber@wikimedia.org wrote:
On Sat, May 20, 2017 at 8:43 PM, Huji Lee huji.huji@gmail.com wrote:
Thanks for taking the time to review these Brion. I will fix every one of them. I am still curious though: how can it only occur some of the time?
A
static script shall always run the same way, no?
The scripts are loaded asynchronously, so if there's no dependency declared there's no guarantee of the ordering that they are executed in.
If you have modules A and B where B uses A in a "$(function(){...})" block, then you have several possibilities depending on which network request completes first:
- module A, then module B, then HTML -> works
- module B, then module A, then HTML -> works
- module A, then HTML, then module B -> works
- module B, then HTML, then module A -> fails
- HTML, then module A, then module B -> works
- HTML, then module B, then module A -> fails
Depending on network conditions, size of pages & modules, what's enabled, and what's cached in your browser, you could land on any of those possibilities.
-- brion _______________________________________________ MediaWiki-l mailing list To unsubscribe, go to: https://lists.wikimedia.org/mailman/listinfo/mediawiki-l