PerformanceResourceTiming.encodedBodySize

The encodedBodySize read-only property represents the size (in octets) received from the fetch (HTTP or cache), of the payload body, before removing any applied content-codings.

Note: This feature is available in Web Workers

If the resource is retrieved from an application cache or a local resource, it must return the size of the payload body before removing any applied content-codings.

Value

A number representing the size (in octets) received from the fetch (HTTP or cache), of the payload body, before removing any applied content-codings.

Examples

The following example, the value of the size properties of all "resource" type events are logged.

function logSizes(entry) {
  // Check for support of the PerformanceEntry.*size properties and print their values
  // if supported.
  console.log(`decodedBodySize = ${perfEntry.decodedBodySize ?? "NOT supported"}`);
  console.log(`encodedBodySize = ${perfEntry.encodedBodySize ?? "NOT supported"}`);
  console.log(`transferSize = ${perfEntry.transferSize ?? "NOT supported"}`);
}

function checkPerformanceEntries() {
  // Use getEntriesByType() to just get the "resource" events
  const entries = performance.getEntriesByType("resource");
  for (const entry of entries) {
    logSizes(entry);
  }
}

Specifications

Specification
Resource Timing Level 2
# dom-performanceresourcetiming-encodedbodysize

Browser compatibility

BCD tables only load in the browser