Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to calculate approximately the connection speed of a website using JavaScript?

How to calculate approximately the connection speed of a website using JavaScript?

I want to create a javascript widget like, which will calculate the speed opening the current opened page.

I am asking if this can be done using just javascript and what will be the idea.

Update

Note that the page size is always Unknown.

like image 389
Amr Elgarhy Avatar asked May 20 '09 17:05

Amr Elgarhy


1 Answers

Here's an example using AJAX with .Net backend, though it could be anything.

Here's a simpler example using an image.

The key is to have a page/object of a known size and capture the start and end times as the browser retrieves it. Then simply divide the size by some [unit of time] to get [size] per [unit of time]. Then use math to translate this into whatever you want.

like image 167
Ryan Emerle Avatar answered Sep 29 '22 20:09

Ryan Emerle