How to get current page size in KB using just javascript?

后端 未结 5 1477
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-06 02:48

Referring to this question , how can i get the current page size in kb, this size i will use to know the connection speed for this page.

5条回答
  •  独厮守ぢ
    2020-12-06 03:47

    Unless your page has size in megabytes, the result will be meaningless.

    This is because time needed to connect, send request, and wait for server to send reply back is quite large compared to time required to download the page, and in addition to that TCP/IP has slow start.

    You also have to take into account caches, proxies and number of parallel connections that browser will make (e.g. may prioritize download of scripts and styles, making page download time appear slow).

提交回复
热议问题