How to detect internet speed in JavaScript?

前端 未结 9 1500
萌比男神i
萌比男神i 2020-11-22 01:56

How can I create a JavaScript page that will detect the user’s internet speed and show it on the page? Something like “your internet speed is ??/?? Kb/s”.

9条回答
  •  别那么骄傲
    2020-11-22 02:45

    thanks to Punit S answer, for detecting dynamic connection speed change, you can use the following code :

    navigator.connection.onchange = function () {
     //do what you need to do ,on speed change event
     console.log('Connection Speed Changed');
    }
    

提交回复
热议问题