resourceloader: Remove module stringification from execute path
authorTimo Tijhof <krinklemail@gmail.com>
Fri, 31 Aug 2018 03:02:18 +0000 (04:02 +0100)
committerKrinkle <krinklemail@gmail.com>
Tue, 4 Sep 2018 17:55:25 +0000 (17:55 +0000)
commite56e159424666dbfac66d6712ba75fbee5188da8
tree482942b4ac9eaf49b431620d9c2a854dec522f61
parent235f3409d1b0b8ab61a01b1e14c2714e7ecb98a7
resourceloader: Remove module stringification from execute path

After execute() is finished and markModuleReady() is called,
the execute path reaches handlePending() which calls
mw.loader.store.set(). This prepares the contents of the module
we just finished executing, for localStorage.

While the writing to localStorage was already debounced via #update,
the stringification of all functions and stylesheets was still
happening within the execute path, and other checks as well.

This commit replaces the mw.loader.store.set() call with a new
method mw.loader.store.add(). The serialisation is now performed
as part of flushWrites(), which is the debounced update that
happens in an idle callback.

While mw.loader.store is itself private within mw.loader, this
commit also marks the set() and update() methods as @private
within mw.loader.store as they are not (and should not) called
from outside this class.

Bug: T202703
Bug: T127328
Change-Id: I23ef28e096acf3bab57b88922ba21366fed06155
resources/src/startup/mediawiki.js
tests/qunit/suites/resources/mediawiki/mediawiki.loader.test.js