I'm trying to calculate the speed of the connection in MB of a user who accesses my site. But I could not find much on the internet besides programs that are ready and sites that already do that. The only thing I was able to do was to calculate how long in milliseconds the page takes to load:
$(window).load(function () {
var endTime = (new Date()).getTime();
var millisecondsLoading = endTime - startTime;
console.log(millisecondsLoading);
// Put millisecondsLoading in a hidden form field
// or Ajax it back to the server or whatever.
});
But I do not know how to use this to calculate the connection speed in a user's MB!