Firefox Tomorrow

web api instance property

PerformanceEntry: name property

View on MDN ↗

Available in workers

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.

Subclass Value
[`LargestContentfulPaint`](/firefox/mdn/api/largestcontentfulpaint/) Always returns an empty string.
[`LayoutShift`](/firefox/mdn/api/layoutshift/) Always returns "layout-shift".
[`PerformanceElementTiming`](/firefox/mdn/api/performanceelementtiming/) One of the following strings:
  • "image-paint"
  • "text-paint"
[`PerformanceEventTiming`](/firefox/mdn/api/performanceeventtiming/) The associated event's type.
[`PerformanceLongTaskTiming`](/firefox/mdn/api/performancelongtasktiming/) One of the following strings:
  • "cross-origin-ancestor"
  • "cross-origin-descendant"
  • "cross-origin-unreachable"
  • "multiple-contexts"
  • "same-origin-ancestor"
  • "same-origin-descendant"
  • "same-origin"
  • "self"
  • "unknown"
[`PerformanceMark`](/firefox/mdn/api/performancemark/) The name used when the mark was created by calling [`performance.mark()`](/firefox/mdn/api/performance/mark/).
[`PerformanceMeasure`](/firefox/mdn/api/performancemeasure/) The name used when the measure was created by calling [`performance.measure()`](/firefox/mdn/api/performance/measure/).
[`PerformanceNavigationTiming`](/firefox/mdn/api/performancenavigationtiming/) The resolved URL of the requested resource. Note that this omits any text fragments or other fragment directives. The value doesn't change even if the request is redirected.
[`PerformancePaintTiming`](/firefox/mdn/api/performancepainttiming/) One of the following strings:
  • "first-paint"
  • "first-contentful-paint"
[`PerformanceResourceTiming`](/firefox/mdn/api/performanceresourcetiming/) The resolved URL of the requested resource. This value doesn't change even if the request is redirected.
[`TaskAttributionTiming`](/firefox/mdn/api/taskattributiontiming/) Always returns "unknown".
[`VisibilityStateEntry`](/firefox/mdn/api/visibilitystateentry/) One of the following strings:
  • "visible"
  • "hidden"

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.

// 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 getEntriesByName() or getEntriesByName().

// 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

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.

See also