MDN self-hosted library · e01.org

PerformanceServerTiming: toJSON() method

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

js
const observer = new PerformanceObserver((list) => {
  list.getEntries().forEach((entry) => {
    entry.serverTiming.forEach((serverTiming) => {
      const json = serverTiming.toJSON();
      console.log(json); // A plain object
      console.log(typeof json); // "object"
      console.log(json.name); // Same value as serverTiming.name
    });
  });
});

["navigation", "resource"].forEach((type) =>
  observer.observe({ type, buffered: true }),
);
js
console.log(JSON.stringify(serverTiming));