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)
It 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");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With