PerformanceServerTiming: name property
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2023.
Note: This feature is available inWeb Workers.
Thename read-only property returns astring value of the server-specified metric name.
In this article
Value
A string.
Examples
>Logging server timing entries
Server timing metrics require the server to send theServer-Timing header. For example:
Server-Timing: cache;desc="Cache Read";dur=23.2TheserverTiming entries can live onnavigation andresource entries.
Example using aPerformanceObserver, which notifies of newnavigation andresource performance entries as they are recorded in the browser's performance timeline. Use thebuffered option to access entries from before the observer creation.
const observer = new PerformanceObserver((list) => { list.getEntries().forEach((entry) => { entry.serverTiming.forEach((serverEntry) => { console.log( `${serverEntry.name} (${serverEntry.description}) duration: ${serverEntry.duration}`, ); // Logs "cache (Cache Read) duration: 23.2" }); });});["navigation", "resource"].forEach((type) => observer.observe({ type, buffered: true }),);Example usingPerformance.getEntriesByType(), which only showsnavigation andresource performance entries present in the browser's performance timeline at the time you call this method:
for (const entryType of ["navigation", "resource"]) { for (const { name: url, serverTiming } of performance.getEntriesByType( entryType, )) { if (serverTiming) { for (const { name, description, duration } of serverTiming) { console.log(`${name} (${description}) duration: ${duration}`); // Logs "cache (Cache Read) duration: 23.2" } } }}Specifications
| Specification |
|---|
| Server Timing> # dom-performanceservertiming-name> |