MDN self-hosted library · e01.org

Navigation and resource timings

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

js
let time = window.performance.timing;
js
const dns = time.domainLookupEnd - time.domainLookupStart;
const tcp = time.connectEnd - time.connectStart;
const tls = time.requestStart - time.secureConnectionStart;
js
const ttfb = time.responseStart - time.navigationStart;
js
let pageloadTime = time.loadEventStart - time.navigationStart;
js
const dns = time.domainLookupEnd - time.domainLookupStart;
js
const tcp = time.connectEnd - time.connectStart;
js
const tls = time.requestStart - time.secureConnectionStart;
js
performance.getEntriesByType("navigation").forEach((navigation) => {
  console.dir(navigation);
});

performance.getEntriesByType("resource").forEach((resource) => {
  console.dir(resource);
});

performance.getEntriesByType("mark").forEach((mark) => {
  console.dir(mark);
});

performance.getEntriesByType("measure").forEach((measure) => {
  console.dir(measure);
});

performance.getEntriesByType("paint").forEach((paint) => {
  console.dir(paint);
});

performance.getEntriesByType("frame").forEach((frame) => {
  console.dir(frame);
});
js
const navigationTimings = performance.getEntriesByType("navigation");
js
const timing = performance.getEntriesByType("navigation")[0];
js
const protocol = timing.nextHopProtocol;
js
const compressionSavings = 1 - timing.transferSize / timing.decodedBodySize;
js
const compressionSavings = 1 - timing.encodedBodySize / timing.decodedBodySize;
js
const request = timing.responseStart - timing.requestStart;
js
const load = timing.loadEventEnd - timing.loadEventStart;
js
const DOMContentLoaded =
  timing.domContentLoadedEventEnd - timing.domContentLoadedEventStart;