PerformanceEntry.name

The name property of the PerformanceEntry interface returns a value that further specifies the value returned by the PerformanceEntry.entryType property. This property is read only.

Note: This feature is available in Web Workers

Value

The return value depends on the subtype of the PerformanceEntry object and the value of PerformanceEntry.entryType, as shown by the table below.

Value Subtype entryType values Description
URL PerformanceNavigationTiming frame, navigation The document's address.
URL PerformanceResourceTiming resource The resolved URL of the requested resource. This value doesn't change even if the request is redirected.
string PerformanceMark mark The name used when the mark was created by calling performance.mark().
string PerformanceMeasure measure name used when the measure was created by calling performance.measure().
string PerformancePaintTiming paint Either 'first-paint' or 'first-contentful-paint'.

Examples

The following example shows the use of the name property.

function runPerformanceEntry() {
  console.log("PerformanceEntry support…");

  if (performance.mark === undefined) {
    console.log("The property performance.mark is not supported");
    return;
  }

  // Create some performance entries via the mark() method
  performance.mark("Begin");
  do_work(50000);
  performance.mark("End");

  // Use getEntries() to iterate through the each entry
  performance.getEntries()
    .forEach((entry, i) => {
      console.log(`Entry[${i}]`);
      checkPerformanceEntry(entry);
    });
}

function checkPerformanceEntry(obj) {
  const properties = ["name", "entryType", "startTime", "duration"];
  const methods = ["toJSON"];

  // Check each property
  properties.forEach((property) => {
    const supported = property in obj;
    console.log(`${property} = ${supported ? obj[property] : "Not supported"}`);
  });

  // Check each method
  methods.forEach((method) => {
    const supported = typeof obj[method] === "function";
    console.log(`${method} = ${supported ? JSON.stringify(obj[method]()) : "Not supported"}`);
  });
}

Specifications

Specification
Performance Timeline
# dom-performanceentry-name

Browser compatibility

BCD tables only load in the browser