performance.getEntriesByType()

The getEntriesByType() method returns an array of PerformanceEntry objects currently present in the performance timeline for a given type.

If you are interested in performance entries of certain name, see getEntriesByName(). 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

getEntriesByType(type)

Parameters

type

The type of entry to retrieve such as "mark". The valid entry types are listed in PerformanceEntry.entryType. The supported entryTypes can be retrieved using the static property PerformanceObserver.supportedEntryTypes.

Return value

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

Examples

Logging resource entries

The following example logs all entries with the type "resource".

const resources = performance.getEntriesByType("resource");
resources.forEach((entry) => {
  console.log(`${entry.name}'s startTime: ${entry.startTime}`);
});

Specifications

Specification
Performance Timeline
# dom-performance-getentriesbytype

Browser compatibility

BCD tables only load in the browser

See also