How to get HTTP protocol version via JavaScript

Is it possible to determine the version of the HTTP protocol using JavaScript? I need to determine if the user is using the HTTP / 2 protocol (and congratulate him if that is the case).

+4
source share
2 answers

Only works in Chrome at the moment, but other browsers should be available soon.

console.log(performance.getEntries()[0].nextHopProtocol)

+1
source
if (location.protocol == "http/2"){
    alert('congratulations!');
}
-1
source

All Articles