'Data Transfer size from server to browser (Data downloaded/bandwidth usage)

I am working on a video streaming application in javascript, i want to tell user how much mbs of data user have consumed/used or how much data has been transferred from server to your browser.

I can see the data transfer size in network tab of browser but i don't know the right way to get the actual transfer size of data from server to browser pragmatically on client side.

I have found a browser performance API that is PerformanceResourceTiming API. This api provide data transfer size attribute but it is not working in safari browser.

What is the right way to do find actual data size transferred and which works on every browser/environment



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source