PerformanceResourceTiming

PerformanceResourceTiming interface enables retrieval and analysis of detailed network timing data regarding the loading of an application's resources . An application can use the timing metrics to determine, for example, the length of time it takes to fetch a specific resource, such as an XMLHttpRequest , <SVG> , image, or script.

The interface's properties create a resource loading timeline with high-resolution timestamps for network events such as redirect start and end times, fetch start, DNS lookup start and end times, response start and end times, etc.. Additionally, the interface extends PerformanceEntry with other properties which provide data about the size of the fetched resource as well as the type of resource that initiated the fetch.

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

特性

This interface extends the following PerformanceEntry properties for resource performance entry types by qualifying and constraining them as follows:

PerformanceEntry.entryType 只读
返回 "resource" .
PerformanceEntry.name 只读
Returns the resources URL.
PerformanceEntry.startTime 只读
返回 timestamp for the time a resource fetch started. This value is equivalent to PerformanceEntry.fetchStart .
PerformanceEntry.duration 只读
返回 timestamp that is the difference between the responseEnd startTime 特性。

The interface also supports the following properties which are listed in the order in which they are recorded for the fetching of a single resource. An alphabetical listing is shown in the navigation, at left.

PerformanceResourceTiming.initiatorType 只读
A string representing the type of resource that initiated the performance entry, as specified in PerformanceResourceTiming.initiatorType .
PerformanceResourceTiming.nextHopProtocol 只读
A string representing the network protocol used to fetch the resource, as identified by the ALPN Protocol ID (RFC7301) .
PerformanceResourceTiming.workerStart 只读
返回 DOMHighResTimeStamp immediately before dispatching the FetchEvent if a Service Worker thread is already running, or immediately before starting the Service Worker thread if it is not already running. If the resource is not intercepted by a Service Worker the property will always return 0.
PerformanceResourceTiming.redirectStart 只读
A DOMHighResTimeStamp that represents the start time of the fetch which initiates the redirect.
PerformanceResourceTiming.redirectEnd 只读
A DOMHighResTimeStamp immediately after receiving the last byte of the response of the last redirect.
PerformanceResourceTiming.fetchStart 只读
A DOMHighResTimeStamp immediately before the browser starts to fetch the resource.
PerformanceResourceTiming.domainLookupStart 只读
A DOMHighResTimeStamp immediately before the browser starts the domain name lookup for the resource.
PerformanceResourceTiming.domainLookupEnd 只读
A DOMHighResTimeStamp representing the time immediately after the browser finishes the domain name lookup for the resource.
PerformanceResourceTiming.connectStart 只读
A DOMHighResTimeStamp immediately before the browser starts to establish the connection to the server to retrieve the resource.
PerformanceResourceTiming.connectEnd 只读
A DOMHighResTimeStamp immediately after the browser finishes establishing the connection to the server to retrieve the resource.
PerformanceResourceTiming.secureConnectionStart 只读
A DOMHighResTimeStamp immediately before the browser starts the handshake process to secure the current connection.
PerformanceResourceTiming.requestStart 只读
A DOMHighResTimeStamp immediately before the browser starts requesting the resource from the server.
PerformanceResourceTiming.responseStart 只读
A DOMHighResTimeStamp immediately after the browser receives the first byte of the response from the server.
PerformanceResourceTiming.responseEnd 只读
A DOMHighResTimeStamp immediately after the browser receives the last byte of the resource or immediately before the transport connection is closed, whichever comes first.
PerformanceResourceTiming.transferSize 只读
A number representing the size (in octets) of the fetched resource. The size includes the response header fields plus the response payload body.
PerformanceResourceTiming.encodedBodySize 只读
A number representing the size (in octets) received from the fetch (HTTP or cache), of the payload body , before removing any applied content-codings.
PerformanceResourceTiming.decodedBodySize 只读
A number that is the size (in octets) received from the fetch (HTTP or cache) of the message body , after removing any applied content-codings.
PerformanceResourceTiming.serverTiming 只读
An array of PerformanceServerTiming entries containing server timing metrics.

方法

PerformanceResourceTiming.toJSON()
返回 DOMString that is the JSON representation of the PerformanceResourceTiming 对象。

范例

See the example in 使用资源计时 API .

规范

规范 状态 Comment
Resource Timing Level 1
The definition of 'PerformanceResourceTiming' in that specification.
候选推荐 初始定义。

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
PerformanceResourceTiming Chrome 43 Edge 12 Firefox 40 IE 10 Opera 30 Safari 11 WebView Android 43 Chrome Android 43 Firefox Android 42 Opera Android 30 Safari iOS 11 Samsung Internet Android 4.0
connectEnd Chrome 43 Edge 12 Firefox 40 IE 10 Opera 32 Safari 11 WebView Android 43 Chrome Android 43 Firefox Android 42 Opera Android 32 Safari iOS 11 Samsung Internet Android 4.0
connectStart Chrome 43 Edge 12 Firefox 40 IE 10 Opera 32 Safari 11 WebView Android 43 Chrome Android 43 Firefox Android 42 Opera Android 32 Safari iOS 11 Samsung Internet Android 4.0
decodedBodySize 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
domainLookupEnd Chrome 43 Edge 12 Firefox 40 IE No Opera 30 Safari 11 WebView Android 43 Chrome Android 43 Firefox Android 42 Opera Android 30 Safari iOS 11 Samsung Internet Android 4.0
domainLookupStart Chrome 43 Edge 12 Firefox 40 IE No Opera 30 Safari 11 WebView Android 43 Chrome Android 43 Firefox Android 42 Opera Android 30 Safari iOS 11 Samsung Internet Android 4.0
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
fetchStart Chrome 43 Edge 12 Firefox 40 IE No Opera 30 Safari 11 WebView Android 43 Chrome Android 43 Firefox Android 42 Opera Android 30 Safari iOS 11 Samsung Internet Android 4.0
initiatorType Chrome 43 Edge 12 Firefox 40 IE No Opera 30 Safari 11 WebView Android 43 Chrome Android 43 Firefox Android 42 Opera Android 30 Safari iOS 11 Samsung Internet Android 4.0
nextHopProtocol Chrome 61 Edge 17 Firefox 45 IE No Opera No Safari No WebView Android 61 Chrome Android 61 Firefox Android 45 Opera Android No Safari iOS No Samsung Internet Android 8.0
redirectEnd Chrome 43 Edge 12 Firefox 40 IE No Opera 30 Safari 11 WebView Android 43 Chrome Android 43 Firefox Android 42 Opera Android 30 Safari iOS 11 Samsung Internet Android 4.0
redirectStart Chrome 43 Edge 12 Firefox 40 IE No Opera 30 Safari 11 WebView Android 43 Chrome Android 43 Firefox Android 42 Opera Android 30 Safari iOS 11 Samsung Internet Android 4.0
requestStart Chrome 43 Edge 12 Firefox 40 IE No Opera 30 Safari 11 WebView Android 43 Chrome Android 43 Firefox Android 42 Opera Android 30 Safari iOS 11 Samsung Internet Android 4.0
responseEnd Chrome 43 Edge 12 Firefox 40 IE No Opera 30 Safari 11 WebView Android 43 Chrome Android 43 Firefox Android 42 Opera Android 30 Safari iOS 11 Samsung Internet Android 4.0
responseStart Chrome 43 Edge 12 Firefox 40 IE No Opera 30 Safari 11 WebView Android 43 Chrome Android 43 Firefox Android 42 Opera Android 30 Safari iOS 11 Samsung Internet Android 4.0
secureConnectionStart Chrome 43 Edge 18 Firefox 40 IE No Opera 30 Safari 11 WebView Android 43 Chrome Android 43 Firefox Android 42 Opera Android 30 Safari iOS 11 Samsung Internet Android 4.0
serverTiming Chrome 65 Edge ≤79 Firefox 61 IE No Opera 52 Safari No WebView Android 65 Chrome Android 65 Firefox Android 61 Opera Android 47 Safari iOS No Samsung Internet Android 9.0
toJSON Chrome 43 Edge ≤18 Firefox 40 IE No Opera 30 Safari 11 WebView Android 43 Chrome Android 43 Firefox Android 42 Opera Android 30 Safari iOS 11 Samsung Internet Android 4.0
transferSize 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
Available in workers Chrome 43 Edge ≤18 Firefox 60 IE No Opera 32 Safari 12 WebView Android 43 Chrome Android 43 Firefox Android 60 Opera Android 32 Safari iOS No Samsung Internet Android 4.0
workerStart Chrome 43 Edge 16 Firefox 58 IE No Opera 32 Safari 11 WebView Android 43 Chrome Android 43 Firefox Android 58 Opera Android 32 Safari iOS 11 Samsung Internet Android 4.0

图例

完整支持
完整支持
不支持
不支持

另请参阅