I don't know if its best practise to do this, but core seems to do: (window.RLQ=window.RLQ||[]).push(function () { mw.loader.using('ext.myextension').then(function(){ console.log('library loaded'); }); });
You probably don't have many other options if you are using the Widgets extension. -- Brian On Thu, Apr 4, 2019 at 4:08 PM Bartosz Dziewoński <matma....@gmail.com> wrote: > Best practice is to use the PHP methods which generate the required > wrappers. Have a look at ResourceLoader::makeLoaderConditionalScript() > and ResourceLoader::makeInlineCodeWithModule(). > > Alternatively, if it's possible, it is ideal to put the initialization > code into another module and load it with addMobules() etc. as usual, > instead of inlining the code in the HTML source. > > -- > Bartosz Dziewoński > > _______________________________________________ > Wikitech-l mailing list > Wikitech-l@lists.wikimedia.org > https://lists.wikimedia.org/mailman/listinfo/wikitech-l _______________________________________________ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l