performance.getEntriesByName()

The getEntriesByName() method returns an array of PerformanceEntry objects currently present in the performance timeline with the given name and type.

If you are interested in performance entries of certain types, see getEntriesByType(). For all performance entries, see getEntries().

Note: This method does not notify you about new performance entries; you will only get entries that are present in the performance timeline at the time you call this method. To receive notifications about entries as they become available, use a PerformanceObserver.

Syntax

getEntriesByName(name)
getEntriesByName(name, type)

Parameters

name

The name of the entries to retrieve.

type Optional

The type of entries to retrieve such as "mark". The valid entry types are listed in PerformanceEntry.entryType.

Return value

An Array of PerformanceEntry objects that have the specified name and type. The items will be in chronological order based on the entries' startTime. If no objects meet the specified criteria, an empty array is returned.

Examples

Logging performance markers

The following example logs all PerformanceMark objects named "debug-mark".

const debugMarks = performance.getEntriesByName("debug-mark", "mark");
debugMarks.forEach((entry) => {
  console.log(`${entry.name}'s startTime: ${entry.startTime}`);
});

Specifications

Specification
Performance Timeline
# dom-performance-getentriesbyname

Browser compatibility

BCD tables only load in the browser

See also