Reputation: 272066
Is it possible to determine the HTTP protocol version using JavaScript? I need to detect if the user is using HTTP/2 protocol (and congratulate him if this was the case).
Upvotes: 7
Views: 2455
Reputation: 2797
console.log(performance.getEntries()[0].nextHopProtocol)
See also: https://caniuse.com/mdn-api_performanceresourcetiming_nexthopprotocol
Works in
Upvotes: 7
Reputation: 93
if (location.protocol == "http/2"){
alert('congratulations!');
}
Upvotes: -4