I have a 3D WEBGL web site with takes to much time to load. So I am looking for a piece of code (probably javascript), whereas I can know beforehand the internet speed of the user browsing my site, and if the user is using a slow internet connection (such as 2 MBs), I will divert the user to a more lightweight, low resolution web site. I've searched the internet but could not fine anything helpful.
Asked
Active
Viewed 1,180 times
1 Answers
0
you can achieve this with a little speedtest
just load a file with ajax with a specific size use Date.now() to get a timestamp before and after filedownload and calculate the connection speed with filesize/duration;
so if the downloaded file has a size of 2000 kbytes and the duration was about 1000ms the connection speed was 2000kb/s
Keep in mind - this check isn't accurate - But it will be more accurate as often you test it (calculate average) or download a more sized file

Kapsonfire
- 1,013
- 5
- 17