docs.rodeo

MDN Web Docs mirror

PerformanceElementTiming

{{APIRef("Performance API")}} {{SeeCompatTable}} 

The PerformanceElementTiming interface contains render timing information for image and text node elements the developer annotated with an elementtiming attribute for observation.

Description

The aim of the Element Timing API is to give web developers or analytics tools the ability to measure rendering timestamps of critical elements on a page.

The API supports timing information on the following elements:

The author flags an element for observation by adding the elementtiming attribute on the element.

PerformanceElementTiming inherits from {{domxref("PerformanceEntry")}} .

{{InheritanceDiagram}} 

Instance properties

This interface extends the following {{domxref("PerformanceEntry")}}  properties for event timing performance entry types by qualifying them as follows:

This interface also supports the following properties:

Instance methods

Examples

Observing render time of specific elements

In this example two elements are being observed by adding the elementtiming attribute. A {{domxref("PerformanceObserver")}}  is registered to get all performance entries of type "element" and the buffered flag is used to access data from before observer creation.

<img src="image.jpg" elementtiming="big-image" />
<p elementtiming="text" id="text-id">text here</p>
const observer = new PerformanceObserver((list) => {
  list.getEntries().forEach((entry) => {
    console.log(entry);
  });
});
observer.observe({ type: "element", buffered: true });

Two entries will be output to the console. The first containing details of the image, the second with details of the text node.

Specifications

{{Specifications}} 

Browser compatibility

{{Compat}} 

See also

In this article

View on MDN