The transferSize read-only property represents the size (in octets) of the fetched resource. The size includes the response header fields plus the response payload body (as defined by RFC7230.
If the resource is fetched from a local cache, this property returns zero.
resource.transferSize;
A number representing the size (in octets) of the fetched resource. The size includes the response header fields plus the response payload body (RFC7230).
The following example, the value of size properties of all "resource" type events are logged.
function log_sizes(perfEntry){
// Check for support of the PerformanceEntry.*size properties and print their values
// if supported.
if ("decodedBodySize" in perfEntry)
console.log("decodedBodySize = " + perfEntry.decodedBodySize);
else
console.log("decodedBodySize = NOT supported");
if ("encodedBodySize" in perfEntry)
console.log("encodedBodySize = " + perfEntry.encodedBodySize);
else
console.log("encodedBodySize = NOT supported");
if ("transferSize" in perfEntry)
console.log("transferSize = " + perfEntry.transferSize);
else
console.log("transferSize = NOT supported");
}
function check_PerformanceEntries() {
// Use getEntriesByType() to just get the "resource" events
var p = performance.getEntriesByType("resource");
for (var i=0; i < p.length; i++) {
log_sizes(p[i]);
}
}
| Specification | Status | Comment |
|---|---|---|
| Resource Timing The definition of 'transferSize' in that specification. | Editor's Draft | Initial definition. |
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
|---|---|---|---|---|---|
| Basic support. | 54.0 | No support | No support | 41 | No support |
| Feature | Android | Android Webview | Firefox Mobile (Gecko) | Firefox OS | IE Phone | Opera Mobile | Safari Mobile | Chrome for Android |
|---|---|---|---|---|---|---|---|---|
| Basic support. | No support | 54.0 | No support | No support | No support | 41 | No support | 54.0 |
© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/transferSize