resourceloader: Simplify mwLoadEnd hook implementation
authorTimo Tijhof <krinklemail@gmail.com>
Mon, 7 May 2018 21:57:40 +0000 (22:57 +0100)
committerKrinkle <krinklemail@gmail.com>
Sat, 19 May 2018 10:51:35 +0000 (10:51 +0000)
commit9d2e43df757bc783da9d3faad12d5b017c4bb7ba
tree47dd5c6bbfdfba8767c545d1804100384528d277
parent99a57ca021d6e2c7bb25d927d47d8657e60b48e8
resourceloader: Simplify mwLoadEnd hook implementation

In addition to the high overhead of $.Deferred per-module in
mw.loader.using(), this was also using $.when() and another
Deferred in catch() for casting.

The handler for marking mwLoadEnd needs a Promise in our fallback
for compatibility with the original using() call. But the code
within our fallback does not need to use N promises, for that
we can simply use a counter that we decrement, given we only need
to worry about completion.

So basically, use `Deferred#always(callback)`
instead of `Deferred.catch(=>Defered().resolve)).then(callback)`.

This is in preparation for moving the code to NavigationTiming.

Change-Id: I20514d3fe680fc9384a0f7ce0880652970d86856
resources/src/mediawiki/mediawiki.js