The read-only name property of the PerformanceEntry interface is a string representing the name for a performance entry. It acts as an identifier, but it does not have to be unique. The value depends on the subclass.
Value
A string. The value depends on the subclass of the PerformanceEntry object as shown by the table below.
When the PerformanceEntry is a PerformanceResourceTiming object, the name property refers to the resolved URL of the requested resource. In this case, the name property can be useful to filter out specific resources, for example all SVG images.
js
// Log durations of SVG resources
performance.getEntriesByType("resource").forEach((entry)=>{if(entry.name.endsWith(".svg")){
console.log(`${entry.name}'s duration: ${entry.duration}`);}});
// Log all marks named "debug-marks" at this point in timeconst debugMarks = performance.getEntriesByName("debug-mark","mark");
debugMarks.forEach((entry)=>{
console.log(`${entry.name}'s startTime: ${entry.startTime}`);});// PerformanceObserver version// Log all marks named "debug-marks" when they happenfunctionperfObserver(list, observer){
list.getEntriesByName("debug-mark","mark").forEach((entry)=>{
console.log(`${entry.name}'s startTime: ${entry.startTime}`);});}const observer =newPerformanceObserver(perfObserver);
observer.observe({entryTypes:["measure","mark"]});