The static supportedEntryTypes
read-only property of the PerformanceObserver
interface returns an array of the entryType
values supported by the user agent.
As the list of supported entries varies per browser and is evolving, this property allows web developers to check which are available.
To find out which entryType
values a browser supports, enter PerformanceObserver.supportedEntryTypes into the console. This will return an array of supported values.
PerformanceObserver.supportedEntryTypes;
The following function checks for support of an array of possible entry types. The unsupported types are logged to the console, however this information could be logged to client-side analytics to indicate that the particular type could not be observed.
function detectSupport(entryTypes) {
for (const entryType of entryTypes) {
if (!PerformanceObserver.supportedEntryTypes.includes(entryType)) {
console.log(entryType);
}
}
}
detectSupport(["resource", "mark", "first-input", "largest-contentful-paint"]);