On Jun 5, 2013, at 2:43 PM, vitalif(a)yourcmc.ru wrote:
Hello!
I've got a serious issue with ResourceLoader.
WHAT FOR it's made to load extension ____styles_____ DYNAMICALLY using
JavaScript?!!!!
It's a very bad idea, it leads to page style flickering during load. I.e. first the
page is displayed using only skin CSS and then you see how extension styles are
dynamically applied to it. Of course it's still rather fast, but it's definitely
noticeable, even in Chrome.
Why didn't you just output <link rel="stylesheet"
href="load.php?<ALL MODULES>" /> ??????????
If you need them in the HTML and they are really important, you can use addModuleStyles
instead.
However use it sparingly as using that makes it harder to cache things properly, produces
slightly more http request overhead.
The client side loader allows all kinds of useful cache features, load optimisations,
dependency resolution and rapid global cache puring without requiring a purge of every
single page of the wiki. This is what enables Wikipedia to deploy new code in ~ 5 minutes
globally without invalidating anything in the HTML.
Historically speaking relying on javascript to load styles may seem odd, but nowadays it
is worth it and is in many cases even faster due to being non-blocking (where
appropriate).
Loading with javascript also doesn't mean that it will flicker. That only happens if
the module is loaded from the bottom.
Set 'position' => 'top' in your module and load with addModules() to
load it from the top. That should fix the flash of unstyled content.
-- Krinkle
[1]
http://www.mediawiki.org/wiki/Manual:$wgResourceModules
[2]
http://www.mediawiki.org/wiki/ResourceLoader/Features