Web APIs
PerformanceObserver()
Constructs an observer whose callback receives a PerformanceObserverEntryList and the observer when records are delivered.
Formal Syntax & Structure
javascript syntaxjavascript
new PerformanceObserver(callback)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| callback | function | Entry delivery callback. |
Return Value
PerformanceObserver
New observer.
Working Example
Example Snippetjavascript
(async () => {let observer;try{const result=await new Promise(resolve=>{observer=new PerformanceObserver(list=>resolve(list.getEntries().map(e=>e.name).join(",")));observer.observe({type:"mark"});performance.mark("v16-observed");});console.log(result);}finally{observer?.disconnect();performance.clearMarks("v16-observed");}})()