https://bugzilla.wikimedia.org/show_bug.cgi?id=27488

--- Comment #56 from Roan Kattouw <[email protected]> 2011-08-13 09:30:15 
UTC ---
An interesting technique is used by HeadJS, a script I was made aware of by
some Australian guy in the audience of our OSCON presentation about
ResourceLoader (thanks, Australian guy!). HeadJS has some interesting features
and we may want to look into using it for more things, but there is one very
interesting page we can take out of their book.

Currently, for top-loaded scripts we use document.write() to effectively append
them to the <head>. This works in that they block the loading of the rest of
the page until the script has been downloaded, parsed and run. If your script
can suffer from flashes of unstyled or unbehaviored content, this is exactly
what you want. Otherwise, not so much.

For bottom-loaded scripts, we currently append to the <body>. This means the
page will load first, then the scripts are downloaded in parallel, parsed and
run in order, and only then does document ready happen. This means the page
displays early, but document ready occurs late and it's probably
unstyled/unbehaviored for a while.

What HeadJS does is append the scripts to the <html> tag, in between the <head>
and the <body> tag (in Firefox at least; in IE, it appends to the half-parsed
<body>, if available, because it's apparently 'safer', and I have no idea what
it does in WebKit or Opera). The effect is that the scripts load in parallel,
*while the page is loading*, and don't block document ready. So that's wins all
around.

Adopting this technique will probably make things load faster, but there's a
bigger issue we need to tackle. Currently, we bottom-load a few things that
cause flashes of unstyled/unbehaviored content, such as the toolbar jumping
thing. We need to either top-load those (which will mostly mitigate the issue
but make the page load slower) or, to really fix the problem, tweak them so
they can handle being bottom-loaded. This means we need to reserve space for
things that will be filled in by JS, move some of the toolbar/textarea wrapping
to the PHP side, etc.

The "this week" of about a month ago didn't happen; I apologize for that. While
I was supposed to work on this bug I was also working on reducing the 1.18 code
review backlog, getting HTTPS working, working on ResourceLoader 2 (Gadgets
extension rewrite) and attending two conferences. I'll work on this soon and
hopefully have something within a week.

-- 
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to