Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 1023894 of PerformanceResourceTiming

  • Revision slug: Web/API/PerformanceResourceTiming
  • Revision title: PerformanceResourceTiming
  • Revision id: 1023894
  • Created:
  • Creator: rolfedh
  • Is current revision? Yes
  • Comment

Revision Content

{{APIRef("Resource Timing API")}}

The PerformanceResourceTiming interface enables retrieving and analyzing 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 {{domxref("XMLHttpRequest")}}, {{SVGElement("SVG","SVG element")}}, image, or script.

The interface's properties create a resource loading timeline with {{domxref("DOMHighResTimeStamp","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 {{domxref("PerformanceEntry","performance entries")}} with other properties which provide data about the size of the fetched resource as well as the type of resource that initiated the fetch.

This interface extends the following {{domxref("PerformanceEntry")}} properties by qualifying and constraining these properties for {{domxref("PerformanceEntry","performance entries")}} with an {{domxref("PerformanceEntry.entryType","entry type")}} of "resource":

  • {{domxref("PerformanceEntry.entryType")}} - Set to "resource".
  • {{domxref("PerformanceEntry.name")}} - Set to the resource's URL.
  • {{domxref("PerformanceEntry.startTime")}} - Set to the {{domxref("DOMHighResTimeStamp","timestamp")}} immediately before the browser to {{domxref("PerformanceEntry.fetchStart","fetch the resource")}}.
  • {{domxref("PerformanceEntry.duration")}} - Set to the difference between the resource's {{domxref("PerformanceResourceTiming.responseEnd","responseEnd")}} {{domxref("DOMHighResTimeStamp","timestamp")}} and its {{domxref("PerformanceEntry.startTime","startTime")}} {{domxref("DOMHighResTimeStamp","timestamp")}}.

Properties

{{domxref('PerformanceResourceTiming.initiatorType')}}{{readonlyInline}}
A {{domxref("DOMString","string")}} representing the type of resource that initiated the performance entry, as specified in {{domxref('PerformanceResourceTiming.initiatorType')}}.
{{domxref('PerformanceResourceTiming.nextHopProtocol')}}{{readonlyInline}}
A {{domxref("DOMString","string")}} representing the network protocol used to fetch the resource, as identified by the ALPN Protocol ID (RFC7301).
{{domxref('PerformanceResourceTiming.workerStart')}}{{readonlyInline}}
If the current context is a {{domxref("Worker","worker")}}, returns the {{domxref("DOMHighResTimeStamp")}} immediately before the worker is started that fetches the resource; otherwise zero is returned.
{{domxref('PerformanceResourceTiming.redirectStart')}}{{readonlyInline}}
A {{domxref("DOMHighResTimeStamp")}} that represents the start time of the fetch which initiates the redirect.
{{domxref('PerformanceResourceTiming.redirectEnd')}}{{readonlyInline}}
A {{domxref("DOMHighResTimeStamp")}} immediately after receiving the last byte of the response of the last redirect.
{{domxref('PerformanceResourceTiming.fetchStart')}}{{readonlyInline}}
A {{domxref("DOMHighResTimeStamp")}} immediately before the browser starts to fetch the resource.
{{domxref('PerformanceResourceTiming.domainLookupStart')}}{{readonlyInline}}
A {{domxref("DOMHighResTimeStamp")}} immediately before the browser starts the domain name lookup for the resource.
{{domxref('PerformanceResourceTiming.domainLookupEnd')}}{{readonlyInline}}
A {{domxref("DOMHighResTimeStamp")}} representing the time immediately after the browser finishes the domain name lookup for the resource.
{{domxref('PerformanceResourceTiming.connectStart')}}{{readonlyInline}}
A {{domxref("DOMHighResTimeStamp")}} immediately before the browser starts to establish the connection to the server to retrieve the resource.
{{domxref('PerformanceResourceTiming.connectEnd')}}{{readonlyInline}}
A {{domxref("DOMHighResTimeStamp")}} immediately after the browser finishes establishing the connection to the server to retrieve the resource.
{{domxref('PerformanceResourceTiming.secureConnectionStart')}}{{readonlyInline}}
A {{domxref("DOMHighResTimeStamp")}} immediately before the browser starts the handshake process to secure the current connection.
{{domxref('PerformanceResourceTiming.requestStart')}}{{readonlyInline}}
A {{domxref("DOMHighResTimeStamp")}} immediately before the browser starts requesting the resource from the server.
{{domxref('PerformanceResourceTiming.responseStart')}}{{readonlyInline}}
A {{domxref("DOMHighResTimeStamp")}} immediately after the browser receives the first byte of the response from the server.
{{domxref('PerformanceResourceTiming.responseEnd')}}{{readonlyInline}}
A {{domxref("DOMHighResTimeStamp")}} immediately after the browser receives the last byte of the resource or immediately before the transport connection is closed, whichever comes first.
{{domxref('PerformanceResourceTiming.transferSize')}}{{readonlyInline}}
A number representing the size (in octets) of the fetched resource. The size includes the response header fields plus the response payload body.
{{domxref('PerformanceResourceTiming.encodedBodySize')}}{{readonlyInline}}
A number representing the size (in octets) received from the fetch (HTTP or cahce), of the payload body, before removing any applied content-codings.
{{domxref('PerformanceResourceTiming.decodedBodySize')}}{{readonlyInline}}
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.

Methods

{{domxref("PerformanceResourceTiming.toJSON()")}}
Returns a {{domxref("DOMString")}} that is the JSON representation of the {{domxref("PerformanceResourceTiming")}} object.

Example

See the example in Using the Resource Timing API.

Specifications

Specification Status Comment
{{SpecName('Resource Timing', '#performanceresourcetiming', 'PerformanceResourceTiming')}} {{Spec2('Resource Timing')}} Initial definition.

Browser compatibility

{{CompatibilityTable}}
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support. 43 40 10 32 {{CompatNo}}
Feature Android Firefox Mobile (Gecko) Firefox OS IE Phone Opera Mobile Safari Mobile
Basic support. 4.4 42 {{CompatUnknown}} 10.0 32 {{CompatNo}}

See also

Revision Source

<div>{{APIRef("Resource Timing API")}}</div>

<p>The <strong><code>PerformanceResourceTiming</code></strong> interface enables retrieving and analyzing detailed network timing data regarding the loading of an application's <em>resources</em>. 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 {{domxref("XMLHttpRequest")}}, {{SVGElement("SVG","SVG element")}}, image, or script.</p>

<p>The interface's properties create a <em>resource loading timeline</em> with {{domxref("DOMHighResTimeStamp","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 {{domxref("PerformanceEntry","performance entries")}} with other properties which provide data about the size of the fetched resource as well as the <em>type</em> of resource that initiated the fetch.</p>

<p>This interface extends the following {{domxref("PerformanceEntry")}} properties by qualifying and constraining these properties for {{domxref("PerformanceEntry","performance entries")}} with an {{domxref("PerformanceEntry.entryType","entry type")}} of "<code>resource</code>":</p>

<ul>
 <li>{{domxref("PerformanceEntry.entryType")}} - Set to "<code>resource</code>".</li>
 <li>{{domxref("PerformanceEntry.name")}} - Set to the resource's URL.</li>
 <li>{{domxref("PerformanceEntry.startTime")}} - Set to the {{domxref("DOMHighResTimeStamp","timestamp")}} immediately before the browser to {{domxref("PerformanceEntry.fetchStart","fetch the resource")}}.</li>
 <li>{{domxref("PerformanceEntry.duration")}} - Set to the difference between the resource's {{domxref("PerformanceResourceTiming.responseEnd","responseEnd")}} {{domxref("DOMHighResTimeStamp","timestamp")}} and its {{domxref("PerformanceEntry.startTime","startTime")}} {{domxref("DOMHighResTimeStamp","timestamp")}}.</li>
</ul>

<h2 id="Properties">Properties</h2>

<dl>
 <dt>{{domxref('PerformanceResourceTiming.initiatorType')}}{{readonlyInline}}</dt>
 <dd>A {{domxref("DOMString","string")}} representing the <em>type</em> of resource that initiated the performance entry, as specified in {{domxref('PerformanceResourceTiming.initiatorType')}}.</dd>
 <dt>{{domxref('PerformanceResourceTiming.nextHopProtocol')}}{{readonlyInline}}</dt>
 <dd>A {{domxref("DOMString","string")}} representing the <em>network protocol</em> used to fetch the resource, as identified by the <a href="https://tools.ietf.org/html/rfc7301">ALPN Protocol ID (RFC7301)</a>.</dd>
 <dt>{{domxref('PerformanceResourceTiming.workerStart')}}{{readonlyInline}}</dt>
 <dd>If the current context is a {{domxref("Worker","worker")}}, returns the {{domxref("DOMHighResTimeStamp")}} immediately before the worker is started that fetches the resource; otherwise zero is returned.</dd>
 <dt>{{domxref('PerformanceResourceTiming.redirectStart')}}{{readonlyInline}}</dt>
 <dd>A {{domxref("DOMHighResTimeStamp")}} that represents the start time of the fetch which initiates the redirect.</dd>
 <dt>{{domxref('PerformanceResourceTiming.redirectEnd')}}{{readonlyInline}}</dt>
 <dd>A {{domxref("DOMHighResTimeStamp")}} immediately after receiving the last byte of the response of the last redirect.</dd>
 <dt>{{domxref('PerformanceResourceTiming.fetchStart')}}{{readonlyInline}}</dt>
 <dd>A {{domxref("DOMHighResTimeStamp")}} immediately before the browser starts to fetch the resource.</dd>
 <dt>{{domxref('PerformanceResourceTiming.domainLookupStart')}}{{readonlyInline}}</dt>
 <dd>A {{domxref("DOMHighResTimeStamp")}} immediately before the browser starts the domain name lookup for the resource.</dd>
 <dt>{{domxref('PerformanceResourceTiming.domainLookupEnd')}}{{readonlyInline}}</dt>
 <dd>A {{domxref("DOMHighResTimeStamp")}} representing the time immediately after the browser finishes the domain name lookup for the resource.</dd>
 <dt>{{domxref('PerformanceResourceTiming.connectStart')}}{{readonlyInline}}</dt>
 <dd>A {{domxref("DOMHighResTimeStamp")}} immediately before the browser starts to establish the connection to the server to retrieve the resource.</dd>
 <dt>{{domxref('PerformanceResourceTiming.connectEnd')}}{{readonlyInline}}</dt>
 <dd>A {{domxref("DOMHighResTimeStamp")}} immediately after the browser finishes establishing the connection to the server to retrieve the resource.</dd>
 <dt>{{domxref('PerformanceResourceTiming.secureConnectionStart')}}{{readonlyInline}}</dt>
 <dd>A {{domxref("DOMHighResTimeStamp")}} immediately before the browser starts the handshake process to secure the current connection.</dd>
 <dt>{{domxref('PerformanceResourceTiming.requestStart')}}{{readonlyInline}}</dt>
 <dd>A {{domxref("DOMHighResTimeStamp")}} immediately before the browser starts requesting the resource from the server.</dd>
 <dt>{{domxref('PerformanceResourceTiming.responseStart')}}{{readonlyInline}}</dt>
 <dd>A {{domxref("DOMHighResTimeStamp")}} immediately after the browser receives the first byte of the response from the server.</dd>
 <dt>{{domxref('PerformanceResourceTiming.responseEnd')}}{{readonlyInline}}</dt>
 <dd>A {{domxref("DOMHighResTimeStamp")}} immediately after the browser receives the last byte of the resource or immediately before the transport connection is closed, whichever comes first.</dd>
 <dt>{{domxref('PerformanceResourceTiming.transferSize')}}{{readonlyInline}}</dt>
 <dd>A <code>number</code> representing the size (in octets) of the fetched resource. The size includes the response header fields plus the response payload body.</dd>
 <dt>{{domxref('PerformanceResourceTiming.encodedBodySize')}}{{readonlyInline}}</dt>
 <dd>A <code>number</code> representing the size (in octets) received from the fetch (HTTP or cahce), of the <em>payload body</em>, before removing any applied content-codings.</dd>
 <dt>{{domxref('PerformanceResourceTiming.decodedBodySize')}}{{readonlyInline}}</dt>
 <dd>A <code>number</code> that is the size (in octets) received from the fetch (HTTP or cache) of the <em>message body</em>, after removing any applied content-codings.</dd>
</dl>

<h2 id="Methods">Methods</h2>

<dl>
 <dt>{{domxref("PerformanceResourceTiming.toJSON()")}}</dt>
 <dd>Returns a {{domxref("DOMString")}} that is the JSON representation of the {{domxref("PerformanceResourceTiming")}} object.</dd>
</dl>

<h2 id="Example">Example</h2>

<p>See the example in <a href="/Web/API/Resource_Timing_API/Using_the_Resource_Timing_API">Using the Resource Timing API</a>.</p>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('Resource Timing', '#performanceresourcetiming', 'PerformanceResourceTiming')}}</td>
   <td>{{Spec2('Resource Timing')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<div>{{CompatibilityTable}}</div>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari (WebKit)</th>
  </tr>
  <tr>
   <td>Basic support.</td>
   <td>43</td>
   <td>40</td>
   <td>10</td>
   <td>32</td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>Firefox OS</th>
   <th>IE Phone</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support.</td>
   <td>4.4</td>
   <td>42</td>
   <td>{{CompatUnknown}}</td>
   <td>10.0</td>
   <td>32</td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>

<h2 id="See_also">See also</h2>

<ul>
 <li><a href="/Web/API/Resource_Timing">Resource Timing (Overview)</a></li>
 <li><a href="/Web/API/Resource_Timing_API/Using_the_Resource_Timing_API">Using the Resource Timing API</a></li>
</ul>
Revert to this revision