mw.loader: Buffer cssText in addEmbeddedCSS.
authorTimo Tijhof <ttijhof@wikimedia.org>
Thu, 7 Mar 2013 00:24:05 +0000 (01:24 +0100)
committerTimo Tijhof <ttijhof@wikimedia.org>
Thu, 7 Mar 2013 04:02:47 +0000 (05:02 +0100)
commit705d50c146ae157e636381f28da669048a719ea7
treede724addae43d7946cda8adc7681982f2b9202f2
parente32786c86b776dacae84cd425f7ba3ee76907c3a
mw.loader: Buffer cssText in addEmbeddedCSS.

I52252e699a improved the repaint situation (bug 45810) a
bit, but not as much as we hoped. Inserting a stylesheet and
applying it to the page is a fairly expensive operation.
Invalidating the previous one in the process didn't help, but
fixing that didn't make a lot of difference.

This is a much more significant improvement by reducing the
number of <style> tags in the first place.

When a load.php request is handled, it reponds with many
mw.loader.implement() calls, one directly after the other
(not asynchronous in any way).

In the long term we could change the server side to combine
these better but for now the easiest fix with the largest gain
is to buffer it, yield once, and then insert it all at once.

This means we insert only one <style> for each load.php request.

Bug: 45810
Change-Id: I430fba9998b133a85dd3ac38237dc44b38630a9c
resources/mediawiki/mediawiki.js
tests/qunit/suites/resources/mediawiki/mediawiki.test.js