Connection protocol discovery (HTTP / 2, spdy) from javascript

Is it possible to get the protocol that the browser used to get the active page?
Something like:

performance.navigation.protocol // eg "HTTP/2" or "SPDY/3.1" or "HTTP/1.1" 

I know that you can detect a protocol server and then pass the information, but I'm looking for a JS solution.

(a similar question contains a broken link and no answer)

+8
javascript browser
source share
1 answer

This is standardized as performance.timing.nextHopProtocol , but chrome has a non-standard implementation already under window.chrome.loadTimes().connectionInfo :

 if ( performance && performance.timing.nextHopProtocol ) { console.log('Protocol:' + performance.timing.nextHopProtocol); } else if ( window.chrome && window.chrome.loadTimes ) { console.log('Protocol:' + window.chrome.loadTimes().connectionInfo); } else { console.log("Browser does not expose connection protocol"); } 
+6
source

All Articles