W3cubDocs

/Web APIs

PerformanceElementTiming: renderTime property

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The renderTime read-only property of the PerformanceElementTiming interface returns the render time of the associated element.

Value

A DOMHighResTimeStamp with the render time of the element.

For images this will be the image rendering timestamp. This is defined as the next paint that occurs after the image becomes fully loaded. If the timing allow check fails (as defined by the Timing-allow-origin header) this will return 0.

For text nodes this will be the text rendering timestamp. This is defined as when the element becomes text painted.

Examples

Logging renderTime

In this example an <image> element is being observed by adding the elementtiming attribute. A PerformanceObserver is registered to get all performance entries of type "element" and the buffered flag is used to access data from before observer creation. Calling entry.renderTime returns the render time of the image element.

html

<img
  src="image.jpg"
  alt="a nice image"
  elementtiming="big-image"
  id="myImage" />

js

const observer = new PerformanceObserver((list) => {
  list.getEntries().forEach((entry) => {
    if (entry.identifier === "big-image") {
      console.log(entry.renderTime);
    }
  });
});
observer.observe({ type: "element", buffered: true });

Cross-origin image render time

For security reasons, the value of the renderTime property is 0 if the resource is a cross-origin request. To expose cross-origin render time information, the Timing-Allow-Origin HTTP response header needs to be set.

For example, to allow https://developer.mozilla.org to see renderTime, the cross-origin resource should send:

http

Timing-Allow-Origin: https://developer.mozilla.org

Alternatively, you can use startTime which returns the value of the entry's renderTime if it is not 0, and otherwise the value of this entry's loadTime. However, it is recommended to set the Timing-Allow-Origin header so that the metrics will be more accurate.

If you use startTime, you can flag any inaccuracies by checking if renderTime was used:

js

const isRenderTime = entry.renderTime ? true : false;

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
renderTime 77 79 No No 64 No 77 77 No 55 No 12.0

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/PerformanceElementTiming/renderTime