ElHaix
ElHaix

Reputation: 12986

How to calculate bandwidth usage for Javascript?

I want to calculate how much bandwidth a some Javascript code will consume, based on what I'm seeing in Chrome's developer tools.

The script is initiated through a one-liner Javascript tag, referencing the external JS file.

In the looking at the Initiator and Size Columns:

Initiator                    Size
-------------------------------------------
Default.aspx                 4.39kb
Parser                       10.54kb

That Javascript file exists on my server, so I want to calculate how much bandwidth each call will consume from my server connection (not where Default.aspx resides).

So my server serves up the .JS at 4.39kb - or is that the bandwidth consumption for the request, and the response is 10.54kb?

What does the parser portion refer to, and is it safe to say that the total bandwidth usage to serve up a response for this request 15.47kb from my server?

Thanks.

Upvotes: 1

Views: 1778

Answers (2)

vsevik
vsevik

Reputation: 9659

In the initiator column first line represents file and line number where this request was initiated. Second line represents the type of the initiator. In your case this request was initiated by HTML parser while parsing Default.aspx (your main document I guess).

As you can see from column header, in the size column first line represents size - meaning transfer size, and the second line represents Content size - meaning actual size of the resource data. Resources are often served compressed and this is probably the case here: response size was 4.39kb and script size was 10.54kb after decompression.

There is no any information about request size, but it is usually quite small unless you have uploaded some data by your request.

Please note that in the bottom of network panel there is a line showing total requests count and total transfer size which is probably what you need.

Upvotes: 3

Matt
Matt

Reputation: 75307

You're reading the columns wrong. The two values for the initiator you're seeing are completely unrelated to the two values you're seeing for size for each resource.

The "Parser" value for the initiator means the parser came across a <script> tag and loaded it (or an <img> tag, whatever). A "script" value means a piece of JavaScript demanded the loading of the resource (e.g. setting the src of an <img/> or via AJAX).

The top value in the "Size" columns is what Chrome calls "Size" and the second (smaller/ gray) value is the "Content". Quite what these mean, I'm trying to work out.

It's true that the total bandwidth usage will be the sum of some values from the Size column... but I'm not sure whether it's the top or bottom value. It's also completely unrelated to the "Initiator".

Upvotes: 0

Related Questions