Thanks again, Brion.

As a follow-up note: we were not alone! Many other wikis suffered from the
dependency changes. https://phabricator.wikimedia.org/T164242 is addressing
this across all WMF wikis.

On Sun, May 21, 2017 at 9:01 PM, Brion Vibber <bvib...@wikimedia.org> wrote:

> On Sun, May 21, 2017 at 4:40 PM, Huji Lee <huji.h...@gmail.com> wrote:
>
> > Fair point. What is the ideal way to code on-module-ready in user
> scripts?
> >
>
> If you both need to manipulate part of the page and need a specific module,
> probably this:
>
> // If we haven't already started loading the module, start loading it:
> mw.loader.using('mediawiki.util', function() {
>   // Module is loaded, *but* it's possible the page HTML is not done. Wait
> for it:
>   $( function() {
>     // Now it should be safe to do everything:
>     mw.util.addPortletLink(....);
>   } );
> });
>
> I kind of wish we had a per-user version of the Gadgets interface, in which
> case you could pre-declare the dependency more easily. :) Something to
> think about for later...
>
> -- brion
>
>
> >
> > On Sat, May 20, 2017 at 5:34 PM, Brion Vibber <bvib...@wikimedia.org>
> > wrote:
> >
> > > On Sat, May 20, 2017 at 8:43 PM, Huji Lee <huji.h...@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
> > >
> > _______________________________________________
> > MediaWiki-l mailing list
> > To unsubscribe, go to:
> > https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
> >
> _______________________________________________
> MediaWiki-l mailing list
> To unsubscribe, go to:
> https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
>
_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l

Reply via email to