如何使用JavaScript大致计算网站的连接速度? [英] How to calculate approximately the connection speed of a website using JavaScript?

查看:180
本文介绍了如何使用JavaScript大致计算网站的连接速度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用JavaScript大致计算网站的连接速度?

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

我想创建一个javascript小部件,它将计算打开当前打开页面的速度。

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

我问这是否可以使用javascript和将是什么想法。

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

strong>更新

Update

注意页面大小总是未知。

Note that the page size is always Unknown.

推荐答案

这里的示例使用AJAX with .Net backend,but it can be anything。

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.

这篇关于如何使用JavaScript大致计算网站的连接速度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆