<img
src="image.jpg"
alt="a nice image"
elementtiming="big-image"
id="myImage" />PerformanceElementTiming: toJSON() method / notebook
PerformanceElementTiming: toJSON() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const observer = new PerformanceObserver((list) => {
list.getEntries().forEach((entry) => {
if (entry.identifier === "big-image") {
const json = entry.toJSON();
console.log(json); // A plain object
console.log(typeof json); // "object"
console.log(json.identifier); // Same value as entry.identifier
}
});
});
observer.observe({ type: "element", buffered: true });console.log(JSON.stringify(entry));