-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathnetInfo.html
36 lines (25 loc) · 1.24 KB
/
netInfo.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<html>
<body>
<div id= "netInfo"></div>
<script>
navigator.connection.addEventListener('change', logNetworkInfo);
function logNetworkInfo() {
// Network type that browser uses
document.getElementById('netInfo').innerHTML+= '<br/> type: ' + navigator.connection.type;
// Effective bandwidth estimate
document.getElementById('netInfo').innerHTML+= '<br/> downlink: ' + navigator.connection.downlink + 'Mb/s';
// Effective round-trip time estimate
document.getElementById('netInfo').innerHTML+= '<br/> rtt: ' + navigator.connection.rtt + 'ms';
// Upper bound on the downlink speed of the first network hop
document.getElementById('netInfo').innerHTML+= '<br/> downlinkMax: ' + navigator.connection.downlinkMax + 'Mb/s';
// Effective connection type determined using a combination of recently
// observed rtt and downlink values: ' +
document.getElementById('netInfo').innerHTML+= '<br/> effectiveType: ' + navigator.connection.effectiveType;
// True if the user has requested a reduced data usage mode from the user
// agent.
document.getElementById('netInfo').innerHTML+= '<br/> saveData: ' + navigator.connection.saveData;
}
logNetworkInfo();
</script>
</body>
</html>