Detect connection speed of the user

I want to detect the user’s connection speed to offer an improved website experience. As an example, use 20 records per page pagination, but allow the detection script to change that to higher or lower (as well as other things).

How is the best way to do this, and can someone point me in the right direction?

I also want to detect connection speed when displaying HTML 5 video (which I haven’t looked at yet). Is it best to use the same script for everything, or use a HTML 5 player with that feature in it?

Thanks.

In order to do that you would have to flood their connection, not advisable. You would be better off using Silverlight for your video as that functionality is built in.

See: https://en.wikipedia.org/wiki/Adaptive_Bit_Rate