Checking someones bandwidth and loading content based on it

后端 未结 4 1692
慢半拍i
慢半拍i 2021-02-14 21:36

I have seen a number of questions that don\'t answer this, is it possible to check someones bandwidth using java script and load specific content based on it?

The BBC se

4条回答
  •  南方客
    南方客 (楼主)
    2021-02-14 22:04

    1. Start a timer.
    2. Send a AJAX request to your server, requesting a file of known size.
    3. When the AJAX request's done loading, stop the timer, and calculate the bandwidth from the passed time and file size.

    The problem with JavaScript is that users can disable it. (Which is more common on phones, that happen to be better off with smaller images)

提交回复
热议问题