GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • MDN
  • HTML: Markup language
  • Elements
  • Global attributes
  • Attributes
  • See all…
  • Responsive images
  • HTML cheatsheet
  • Date & time formats
  • See all…
  • SVG
  • MathML
  • XML
  • CSS: Styling language

This view

  • Original page
  • New address

GeezerVison is showing developer.mozilla.org — PerformanceObserver - Web APIs | MDN

PerformanceObserver

Baseline
Widely available
*

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

* Some parts of this feature may have varying levels of support.

  • See full compatibility
  • Learn more

Note: This feature is available in Web 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

PerformanceObserver()

Creates and returns a new PerformanceObserver object.

Static properties

PerformanceObserver.supportedEntryTypes Read only

Returns an array of the entryType values supported by the user agent.

Instance methods

PerformanceObserver.observe()

Specifies the set of entry types to observe. The performance observer's callback function will be invoked when performance entry is recorded for one of the specified entryTypes.

PerformanceObserver.disconnect()

Stops the performance observer callback from receiving performance entries.

PerformanceObserver.takeRecords()

Returns the current list of performance entries stored in the performance observer, emptying it out.

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.

js
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

Specification
Performance Timeline
# performanceobserver

Browser compatibility

See also

  • MutationObserver
  • ResizeObserver
  • IntersectionObserver

Help improve MDN

Learn how to contribute

This page was last modified on Oct 12, 2024 by MDN contributors.

View this page on GitHub • Report a problem with this content
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.