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.

注意: 此特征可用于 Web 工作者 .

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.

句法

resource.encodedBodySize;
				

返回值

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

范例

The following example, the value of the 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]);
  }
}
				

规范

规范 状态 注释
Resource Timing Level 2
The definition of 'encodedBodySize' in that specification.
工作草案 初始定义。

浏览器兼容性

The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
encodedBodySize Chrome 54 Edge 17 Firefox 45 IE 不支持 No Opera 41 Safari 不支持 No WebView Android 54 Chrome Android 54 Firefox Android 45 Opera Android 41 Safari iOS 不支持 No Samsung Internet Android 6.0

图例

完整支持

完整支持

不支持

不支持

元数据

  • 最后修改: