[MediaWiki-commits] [Gerrit] mediawiki/core[master]: mw.loader: Use requestAnimationFrame for addEmbeddedCSS()
jenkins-bot has submitted this change and it was merged. Change subject: mw.loader: Use requestAnimationFrame for addEmbeddedCSS() .. mw.loader: Use requestAnimationFrame for addEmbeddedCSS() setTimeout is fairly inefficient for this purpose as it tends to schedule for further in the future than rAF would. And even then, it happens at a bad time for the browser with regards to style changes. Instead, use rAF, which typically executes earlier and at the point where the browser is expecting style changes. This makes top and bottom modules finish execution earlier by having their styles applied sooner. Change-Id: Ie4e7464aa811fa8ea4e4f115696f0bddbd28737b --- M resources/src/mediawiki/mediawiki.js 1 file changed, 4 insertions(+), 4 deletions(-) Approvals: Gilles: Looks good to me, approved jenkins-bot: Verified diff --git a/resources/src/mediawiki/mediawiki.js b/resources/src/mediawiki/mediawiki.js index 7ceb5fe..78c674c 100644 --- a/resources/src/mediawiki/mediawiki.js +++ b/resources/src/mediawiki/mediawiki.js @@ -858,7 +858,8 @@ cssBuffer = '', cssBufferTimer = null, cssCallbacks = $.Callbacks(), - isIE9 = document.documentMode === 9; + isIE9 = document.documentMode === 9, + rAF = window.requestAnimationFrame || setTimeout; function getMarker() { if ( !marker ) { @@ -930,10 +931,9 @@ if ( !cssBuffer || cssText.slice( 0, '@import'.length ) !== '@import' ) { // Linebreak for somewhat distinguishable sections cssBuffer += '\n' + cssText; - // TODO: Using requestAnimationFrame would perform better by not injecting - // styles while the browser is busy painting. if ( !cssBufferTimer ) { - cssBufferTimer = setTimeout( function () { + cssBufferTimer = rAF( function () { + // Wrap in anonymous function that takes no arguments // Support: Firefox < 13 // Firefox 12 has non-standard behaviour of passing a number // as first argument to a setTimeout callback. -- To view, visit https://gerrit.wikimedia.org/r/307470 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie4e7464aa811fa8ea4e4f115696f0bddbd28737b Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: KrinkleGerrit-Reviewer: Gilles Gerrit-Reviewer: Jack Phoenix Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] mediawiki/core[master]: mw.loader: Use requestAnimationFrame for addEmbeddedCSS()
Krinkle has uploaded a new change for review. https://gerrit.wikimedia.org/r/307470 Change subject: mw.loader: Use requestAnimationFrame for addEmbeddedCSS() .. mw.loader: Use requestAnimationFrame for addEmbeddedCSS() setTimeout is fairly inefficient for this purpose as it tends to schedule for further in the future than rAF would. And even then, it happens at a bad time for the browser with regards to style changes. Instead, use rAF, which typically executes earlier and at the point where the browser is expecting style changes. This makes top and bottom modules finish execution earlier by having their styles applied sooner. Change-Id: Ie4e7464aa811fa8ea4e4f115696f0bddbd28737b --- M resources/src/mediawiki/mediawiki.js 1 file changed, 4 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/70/307470/1 diff --git a/resources/src/mediawiki/mediawiki.js b/resources/src/mediawiki/mediawiki.js index 0c0d3a4..6426480 100644 --- a/resources/src/mediawiki/mediawiki.js +++ b/resources/src/mediawiki/mediawiki.js @@ -858,7 +858,8 @@ cssBuffer = '', cssBufferTimer = null, cssCallbacks = $.Callbacks(), - isIE9 = document.documentMode === 9; + isIE9 = document.documentMode === 9, + rAF = window.requestAnimationFrame || setTimeout; function getMarker() { if ( !marker ) { @@ -930,10 +931,9 @@ if ( !cssBuffer || cssText.slice( 0, '@import'.length ) !== '@import' ) { // Linebreak for somewhat distinguishable sections cssBuffer += '\n' + cssText; - // TODO: Using requestAnimationFrame would perform better by not injecting - // styles while the browser is busy painting. if ( !cssBufferTimer ) { - cssBufferTimer = setTimeout( function () { + cssBufferTimer = rAF( function () { + // Wrap in anonymous function that takes no arguments // Support: Firefox < 13 // Firefox 12 has non-standard behaviour of passing a number // as first argument to a setTimeout callback. -- To view, visit https://gerrit.wikimedia.org/r/307470 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie4e7464aa811fa8ea4e4f115696f0bddbd28737b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Krinkle___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits