Is it possible to get the protocol that the browser used to get the active page?
Something like:
performance.navigation.protocol // e.g. "HTTP/2" or "SPDY/3.1" or "HTTP/1.1"
I know that it's possible to detect the protocol server side and then pass the info, but I'm looking for a JS solution.
(a similar question contains a broken link and no answer)
Is it possible to get the protocol that the browser used to get the active page?
Something like:
performance.navigation.protocol // e.g. "HTTP/2" or "SPDY/3.1" or "HTTP/1.1"
I know that it's possible to detect the protocol server side and then pass the info, but I'm looking for a JS solution.
(a similar question contains a broken link and no answer)
Share Improve this question edited May 23, 2017 at 11:46 CommunityBot 11 silver badge asked Mar 16, 2016 at 16:15 RazorRazor 29.7k8 gold badges56 silver badges77 bronze badges 3-
can you make a HEAD request to
location.href
with ajax? edit: nevermind, i don't see a response prop that would indicate it anyway... – dandavis Commented Mar 16, 2016 at 16:24 - What do you need this for? – Bergi Commented Mar 23, 2016 at 15:01
-
1
performance.getEntries()[0].nextHopProtocol
works in Chrome – everconfusedGuy Commented Sep 8, 2017 at 11:31
1 Answer
Reset to default 11It is being standardised as performance.timing.nextHopProtocol
, but chrome has a non-standard implementation already under window.chrome.loadTimes().connectionInfo
:
if ( window.performance && performance.timing.nextHopProtocol ) {
console.log('Protocol:' + performance.timing.nextHopProtocol);
} else if (window.performance && window.performance.getEntries) {
console.log(performance.getEntries()[0].nextHopProtocol);
} else if ( window.chrome && window.chrome.loadTimes ) {
console.log('Protocol:' + window.chrome.loadTimes().connectionInfo);
} else {
console.log("Browser does not expose connection protocol");
}