Dr0ptp4kt has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/371755 )

Change subject: Preconnect to search target domain
......................................................................

Preconnect to search target domain

Pre-emptively handshake with the target search server.
This will remove some overhead for search requests and,
in the decent chance of a clickthrough on the inferred
language without a search, such clickthrouhgs.

One side effect is an increase in TLS handshakes.

Change-Id: I53e72dc57d565b9fd0d9635d0e97ada6ff9112ae
---
M dev/wikipedia.org/assets/js/wm-portal.js
1 file changed, 16 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/portals 
refs/changes/55/371755/1

diff --git a/dev/wikipedia.org/assets/js/wm-portal.js 
b/dev/wikipedia.org/assets/js/wm-portal.js
index 9b5e797..a25f116 100644
--- a/dev/wikipedia.org/assets/js/wm-portal.js
+++ b/dev/wikipedia.org/assets/js/wm-portal.js
@@ -56,6 +56,21 @@
        }
 
        /**
+        * Preconnects to the search target wiki
+        *
+        * @param {string} lang
+        */
+       function preconnect( lang ) {
+               var link = document.createElement( 'link' ),
+                       domain = window.location.hostname.split( '.' ),
+                       tld = domain.pop(),
+                       sld = domain.pop();
+               link.rel = 'preconnect';
+               link.href = '//' + lang + '.' + sld + '.' + tld;
+               document.head.appendChild( link );
+       }
+
+       /**
         * Returns the user's preferred language according to browser 
preferences.
         *
         * @return {string}
@@ -195,6 +210,7 @@
                        if ( matchingLang ) {
                                select.value = matchingLang;
                                updateBranding( matchingLang );
+                               preconnect( matchingLang );
                        }
                }
        } );

-- 
To view, visit https://gerrit.wikimedia.org/r/371755
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I53e72dc57d565b9fd0d9635d0e97ada6ff9112ae
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/portals
Gerrit-Branch: master
Gerrit-Owner: Dr0ptp4kt <ab...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to