Last modified: 2014-03-11 10:59:01 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T63852, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 61852 - mw.loader.using() doesn't really wait for CSS to be loaded
mw.loader.using() doesn't really wait for CSS to be loaded
Status: NEW
Product: MediaWiki
Classification: Unclassified
ResourceLoader (Other open bugs)
1.23.0
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-02-24 16:06 UTC by Gilles Dubuc
Modified: 2014-03-11 10:59 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Gilles Dubuc 2014-02-24 16:06:03 UTC
While ResourceLoader seems to correctly wait for JS dependencies to be loaded before firing using()'s callback, when it adds CSS to the page, all it does is create <link> elements to the head, not waiting for the CSS content to really be loaded.

Which means that something waiting for CSS dependencies sees its callback called too early, when the required CSS hasn't been loaded yet.

Symptoms in code leveraging mw.loader.using() include broken CSS flashing by (because elements are shown before their styles are applied), or even broken application logic when JS does size-dependent actions fail due to missing styles (the elements aren't the size they will be once the styles are applied).

Afaik modern browsers support the onload event on link elements, so that's probably a solution to explore. If that can't be done, an alternative is to insert a special CSS rule at the end of each CSS file served indicating that the CSS has been loaded, and waiting for that style to appear. The latter is what I'm going to attempt right now as a workaround for MultimediaViewer, which is broken (particularly in Chrome) at the moment because of this bug.
Comment 1 Gilles Dubuc 2014-02-24 17:07:38 UTC
The workaround for Multimedia Viewer: https://gerrit.wikimedia.org/r/115196

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links