speed test connection detection algorithm for html5 & javascript