jenkins-bot has submitted this change and it was merged. Change subject: Pre-fetch RESTBase DNS and negotiate TLS ......................................................................
Pre-fetch RESTBase DNS and negotiate TLS Keep VisualEditor load times snappy by eagerly establishing a connection with RESTBase via a beacon request, which is deferred until after window.onload / setTimeout to ensure it does not slow down the loading of the page. Task: T94784 Change-Id: I19fd2ef6beffe1c4c4f05c2716da079b49e88b95 --- M modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.init.js 1 file changed, 18 insertions(+), 0 deletions(-) Approvals: Catrope: Looks good to me, approved jenkins-bot: Verified diff --git a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.init.js b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.init.js index 7ce7aa3..a441d94 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.init.js +++ b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.init.js @@ -524,6 +524,19 @@ mw.config.get( 'wgPageContentModel' ) === 'wikitext' ); + // Pre-fetch RESTBase DNS and negotiate TLS. + function restbasePreConnect() { + var url, a = document.createElement( 'a' ); + + a.href = conf.restbaseUrl; + url = '//' + a.hostname + '/' + mw.config.get( 'wgServerName' ) + '/v1/'; + if ( navigator.sendBeacon ) { + navigator.sendBeacon( url ); + } else { + new Image().src = url; + } + } + // Note: Though VisualEditor itself only needs this exposure for a very small reason // (namely to access init.blacklist from the unit tests...) this has become one of the nicest // ways to easily detect whether the VisualEditor initialisation code is present. @@ -560,6 +573,11 @@ if ( userPrefEnabled ) { init.setupSkin(); + if ( conf.restbaseUrl ) { + $( window ).load( function () { + setTimeout( restbasePreConnect ); + } ); + } } if ( currentUri.query.venotify ) { -- To view, visit https://gerrit.wikimedia.org/r/203194 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I19fd2ef6beffe1c4c4f05c2716da079b49e88b95 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/VisualEditor Gerrit-Branch: master Gerrit-Owner: Ori.livneh <o...@wikimedia.org> Gerrit-Reviewer: Catrope <roan.katt...@gmail.com> Gerrit-Reviewer: Krinkle <krinklem...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits