File: example.js

package info (click to toggle)
libwebsockets 4.3.5-2
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 31,288 kB
  • sloc: ansic: 194,407; javascript: 1,550; sh: 1,387; cpp: 505; java: 461; perl: 405; xml: 118; makefile: 76; awk: 5
file content (21 lines) | stat: -rw-r--r-- 696 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
document.addEventListener("DOMContentLoaded", function() {

	var transport_protocol = "";
	
	if ( performance && performance.timing.nextHopProtocol ) {
	    transport_protocol = performance.timing.nextHopProtocol;
	} else if ( window.chrome && window.chrome.loadTimes ) {
	    transport_protocol = window.chrome.loadTimes().connectionInfo;
	} else {
	
	  var p = performance.getEntriesByType("resource");
	  for (var i=0; i < p.length; i++) {
		var value = "nextHopProtocol" in p[i];
		  if (value)
		    transport_protocol = p[i].nextHopProtocol;
	    }
	   }
	   
	   if (transport_protocol === "h2")
	   	document.getElementById("transport").innerHTML = "<img src=\"/http2.png\">";
}, false);