The getEntriesByType()
method of the PerformanceObserverEntryList
returns a list of explicitly observed performance entry objects for a given performance entry type. The list's members are determined by the set of entry types specified in the call to the observe()
method. The list is available in the observer's callback function (as the first parameter in the callback).
This method is exposed to Window
and Worker
interfaces.
Syntax
entries = list.getEntriesByType(type);
Parameters
type
- The type of entry to retrieve such as "
frame
". The valid entry types are listed inPerformanceEntry.entryType
.
Return value
A list of explicitly observed 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 list is returned.
Example
function print_perf_entry(pe) { console.log("name: " + pe.name + "; entryType: " + pe.entryType + "; startTime: " + pe.startTime + "; duration: " + pe.duration); } // Create observer for all performance event types var observe_all = new PerformanceObserver(function(list, obs) { var perfEntries; // Print all entries perfEntries = list.getEntries(); for (var i=0; i < perfEntries.length; i++) { print_perf_entry(perfEntries[i]); } // Print entries named "Begin" with type "mark" perfEntries = list.getEntriesByName("Begin", "mark"); for (var i=0; i < perfEntries.length; i++) { print_perf_entry(perfEntries[i]); } // Print entries with type "mark" perfEntries = list.getEntriesByType("mark"); for (var i=0; i < perfEntries.length; i++) { print_perf_entry(perfEntries[i]); } }); // subscribe to all performance event types observe_all.observe({entryTypes: ['frame', 'mark', 'measure', 'navigation', 'resource', 'server']}); var observe_frame = new PerformanceObserver(function(list, obs) { var perfEntries = list.getEntries(); // Should only have 'frame' entries for (var i=0; i < perfEntries.length; i++) { print_perf_entry(perfEntries[i]); } }); // subscribe to only the 'frame' event observe_frame.observe({entryTypes: ['frame']});
Specifications
Specification | Status | Comment |
---|---|---|
Performance Timeline Level 2 The definition of 'getEntriesByType()' in that specification. |
Candidate Recommendation | Initial definition of getEntriesByType() method. |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
getEntriesByType | Chrome Full support 52 | Edge Full support ≤79 | Firefox Full support 57 | IE No support No | Opera Full support 39 | Safari No support No | WebView Android No support No | Chrome Android Full support 52 | Firefox Android Full support 57 | Opera Android Full support 41 | Safari iOS No support No | Samsung Internet Android Full support 6.0 |
Legend
- Full support
- Full support
- No support
- No support