Firefox Tomorrow

web api interface

PerformanceObserver

View on MDN ↗

Available in workers

The PerformanceObserver interface is used to observe performance measurement events and be notified of new performance entries as they are recorded in the browser’s performance timeline.

Constructor

Static properties

Instance methods

Examples

Creating a PerformanceObserver

The following example creates a PerformanceObserver watching for “mark” (PerformanceMark) and “measure” (PerformanceMeasure) events. The perfObserver callback provides a list (PerformanceObserverEntryList) which allows you to get observed performance entries.

function perfObserver(list, observer) {
  list.getEntries().forEach((entry) => {
    if (entry.entryType === "mark") {
      console.log(`${entry.name}'s startTime: ${entry.startTime}`);
    }
    if (entry.entryType === "measure") {
      console.log(`${entry.name}'s duration: ${entry.duration}`);
    }
  });
}
const observer = new PerformanceObserver(perfObserver);
observer.observe({ entryTypes: ["measure", "mark"] });

Specifications

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.

See also