W3cubDocs

/Web APIs

PerformanceEventTiming: target property

The read-only target property returns the associated event's last target which is the node onto which the event was last dispatched.

Value

A Node onto which the event was last dispatched.

Or null if the Node is disconnected from the document's DOM or is in the shadow DOM.

Examples

Observing events with a specific last target

The target property can be used when observing event-timing entries (PerformanceEventTiming). For example, to log and measure events for a given last target only.

js

const observer = new PerformanceObserver((list) => {
  list.getEntries().forEach((entry) => {
    if (entry.target && entry.target.id === "myNode") {
      const delay = entry.processingStart - entry.startTime;
      console.log(entry.name, delay);
    }
  });
});

// Register the observer for events
observer.observe({ type: "event", buffered: true });

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
target 85 85 89 No 71 No 85 85 89 60 No 14.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/PerformanceEventTiming/target