Using JavaScript to estimate connection speed
An item very high up on the wish list for people building responsive sites is information about connection speed. This information is not made available to us by browsers but, by using JavaScript and timing information in the page, we can estimate it. Once we have this information we can then selectively load larger assets such as images.
An excerpt from Using JavaScript to estimate connection speed