Is there a way to get the total size of files transferred to a page in real time using Javascript?

I am looking for a way to find out how many KB information was transferred as a web page uploads . It would be nice to say:

loadedSoFar = window.document.loadedKB;

Two promising uses are checking connection speed or drawing a progress bar.

The Mac has an Activity Monitor app that can provide network usage.

Essentially, I'm looking for real-time network usage information through Javascript.

Is there such a tool or feature?

Ideally, this will work without my calculation of the number of files of all page components.

+4
source share
2 answers

No no.

JavaScript does not have access to network traffic.

+1
source

If the goal is to create a boot panel or bandwidth measure, you can send a client with file statistics. Most minimally, if your script is allowed to "detect" the nodes responsible for downloading each file and to monitor their download events, or if the script can be directly responsible for downloading files, you can at least show the progress in the files downloaded by shared files.

In addition to this, and for more detailed statistics, you can populate the script with the profile of the downloaded files, given the compressed gzip sizes. This will allow you to show the average as files arrive.

+1
source

Source: https://habr.com/ru/post/1616046/


All Articles