mw.loader: Create new style tags instead of appending text
authorTimo Tijhof <ttijhof@wikimedia.org>
Wed, 6 Mar 2013 23:02:51 +0000 (00:02 +0100)
committerTimo Tijhof <ttijhof@wikimedia.org>
Thu, 7 Mar 2013 04:02:44 +0000 (05:02 +0100)
commite32786c86b776dacae84cd425f7ba3ee76907c3a
treee54a6cab1825343a5ec63c54873e6cd91746a015
parent851f669b185f2b0570d78b3c0ffd209c983b880f
mw.loader: Create new style tags instead of appending text

As brought to our attention by Chromium/WebKit developers at Google,
when we fixed bug 31676 (IE stylesheet limit) by appending to
<style> whenever we can (i.e. whenever the received stylesheet
does not involve @import which only works on top of the a
stylesheet) – this is causing several slowdowns.

Which build up on mobile to several dozen seconds in pages
with a lot of content and many modules being loaded.

Appending a text node to a <style> tag, while it doesn't require
the DOM to do anything fancy (no need to reparse the contents).
The stylesheet handler of the browser has to re-parse the css text
after each modification as the css syntax is too tolerant to be
able to just pick up parsing again (at least, as of writing
neither Gecko or WebKit are able to do so).

As a result, the stylesheet is invalidated, re-parsed and
re-applied to the page.

So instead default the other way around and only re-use a <style>
tag if we have to do so for IE.

Bug: 45810
Change-Id: I52252e699a518dc1c1327ee598a9e023cc2555e2
resources/mediawiki/mediawiki.js