PerformanceEntry: name property
Performance API
Performance API
The read-only **`name`** property of the PerformanceEntry interface is a string representing the name for a performance entry. It acts as an identifier, but it does not have to be unique. The value depends on the subclass.
## Value
A string. The value depends on the subclass of the `PerformanceEntry` object as shown by the table below.
<table class="no-markdown">
<thead>
<tr>
<th scope="col">Subclass</th>
<th scope="col">Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>InteractionContentfulPaint</td>
<td>Always returns an empty string.</td>
</tr>
<tr>
<td>LargestContentfulPaint</td>
<td>Always returns an empty string.</td>
</tr>
<tr>
<td>LayoutShift</td>
<td>Always returns an empty string.</td>
</tr>
<tr>
<td>PerformanceContainerTiming</td>
<td>Always returns an empty string.</td>
</tr>
<tr>
<td>PerformanceElementTiming</td>
<td>One of the following strings:
<ul>
<li><code>"image-paint"</code></li>
<li><code>"text-paint"</code></li>
</ul>
</td>
</tr>
<tr>
<td>PerformanceEventTiming</td>
<td>The associated event's type.</td>
</tr>
<tr>
<td>PerformanceLongAnimationFrameTiming</td>
<td>Always returns <code>"long-animation-frame"</code>.</td>
</tr>
<tr>
<td>PerformanceLongTaskTiming</td>
<td>One of the following strings:
<ul>
<li><code>"cross-origin-ancestor"</code></li>
<li><code>"cross-origin-descendant"</code></li>
<li><code>"cross-origin-unreachable"</code></li>
<li><code>"multiple-contexts"</code></li>
<li><code>"same-origin-ancestor"</code></li>
<li><code>"same-origin-descendant"</code></li>
<li><code>"same-origin"</code></li>
<li><code>"self"</code></li>
<li><code>"unknown"</code></li>
</ul>
</td>
</tr>
<tr>
<td>PerformanceMark</td>
<td>
The name used when the mark was created by calling
performance.mark().
</td>
</tr>
<tr>
<td>PerformanceMeasure</td>
<td>
The name used when the measure was created by calling
performance.measure().
</td>
</tr>
<tr>
<td>PerformanceNavigationTiming</td>
<td>The resolved URL of the requested resource.
Note that this omits any <a href="/en-US/docs/Web/URI/Reference/Fragment/Text_fragments">text fragments</a> or other fragment directives.
The value doesn't change even if the request is redirected.
</td>
</tr>
<tr>
<td>PerformancePaintTiming</td>
<td>One of the following strings:
<ul>
<li><code>"first-paint"</code></li>
<li><code>"first-contentful-paint"</code></li>
</ul>
</td>
</tr>
<tr>
<td>PerformanceResourceTiming</td>
<td>The resolved URL of the requested resource. This value doesn't change even if the request is redirected.</td>
</tr>
<tr>
<td>PerformanceSoftNavigation</td>
<td>The new URL navigated to.</td>
</tr>
<tr>
<td>TaskAttributionTiming</td>
<td>Always returns <code>"unknown"</code>.</td>
</tr>
<tr>
<td>VisibilityStateEntry</td>
<td>One of the following strings:
<ul>
<li><code>"visible"</code></li>
<li><code>"hidden"</code></li>
</ul>
</td>
</tr>
</tbody>
</table>
## Examples
### Filtering performance entries by name
When the `PerformanceEntry` is a PerformanceResourceTiming object, the `name` property refers to the resolved URL of the requested resource.
In this case, the `name` property can be useful to filter out specific resources, for example all SVG images.
```js
// Log durations of SVG resources
performance.getEntriesByType("resource").forEach((entry) => {
if (entry.name.endsWith(".svg")) {
console.log(`${entry.name}'s duration: ${entry.duration}`);
}
});
```
### Getting performance entries by name
Both Performance and PerformanceObserver provide methods that allow you to get performance entries by name directly. You don't necessarily need the `name` property for that, instead you might use Performance.getEntriesByName() or PerformanceObserverEntryList.getEntriesByName().
```js
// Log all marks named "debug-marks" at this point in time
const debugMarks = performance.getEntriesByName("debug-mark", "mark");
debugMarks.forEach((entry) => {
console.log(`${entry.name}'s startTime: ${entry.startTime}`);
});
// PerformanceObserver version
// Log all marks named "debug-marks" when they happen
function perfObserver(list, observer) {
list.getEntriesByName("debug-mark", "mark").forEach((entry) => {
console.log(`${entry.name}'s startTime: ${entry.startTime}`);
});
}
const observer = new PerformanceObserver(perfObserver);
observer.observe({ entryTypes: ["measure", "mark"] });
```
## Specifications
## Browser compatibility
## See also
- Performance.getEntriesByName()
- PerformanceObserverEntryList.getEntriesByName()
Cite this
"PerformanceEntry: name property". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/API/PerformanceEntry/name JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy