r108235 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108234‎ | r108235 | r108236 >
Date:15:06, 6 January 2012
Author:catrope
Status:ok
Tags:
Comment:
Followup r108184: fix loading in Opera. Before, Opera would only begin to render the document after all async scripts were loaded, now it's the other way around (scripts load after the document is ready). This is not an improvement compared to the current situation, but it's not a regression either.
Modified paths:
  • /trunk/phase3/resources/mediawiki/mediawiki.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/mediawiki/mediawiki.js
@@ -631,11 +631,20 @@
632632 }
633633 };
634634 }
635 - // IE-safe way of getting the <head> . document.documentElement.head doesn't
636 - // work in scripts that run in the <head>
637 - head = document.getElementsByTagName( 'head' )[0];
638 - // Append to the <body> if available, to the <head> otherwise
639 - (document.body || head).appendChild( script );
 635+
 636+ if ( window.opera ) {
 637+ // Appending to the <head> blocks rendering completely in Opera,
 638+ // so append to the <body> after document ready. This means the
 639+ // scripts only start loading after the document has been rendered,
 640+ // but so be it. Opera users don't deserve faster web pages if their
 641+ // browser makes it impossible
 642+ $( function() { document.body.appendChild( script ); } );
 643+ } else {
 644+ // IE-safe way of getting the <head> . document.documentElement.head doesn't
 645+ // work in scripts that run in the <head>
 646+ head = document.getElementsByTagName( 'head' )[0];
 647+ ( document.body || head ).appendChild( script );
 648+ }
640649 } else {
641650 document.write( mw.html.element(
642651 'script', { 'type': 'text/javascript', 'src': src }, ''

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r108184ResourceLoader: Add an experimental option to move the main module loading qu...catrope23:32, 5 January 2012

Status & tagging log