PerformanceResourceTiming.initiatorType

The initiatorType read-only property is a string that represents the type of resource that initiated the performance event.

The value of this string is as follows:

  • If the initiator is a Element, the property returns the element's localName.
  • If the initiator is a CSS resource, the property returns "css".
  • If the initiator is a XMLHttpRequest object, the property returns "xmlhttprequest".
  • If the initiator is a PerformanceNavigationTiming object, the property returns an empty string ("").

Note: This feature is available in Web Workers

Value

A string representing the type of resource that initiated the performance event, as specified above.

Examples

function printPerformanceEntries() {
  // Use getEntriesByType() to just get the "resource" events
  performance.getEntriesByType("resource")
    .forEach((entry) => {
      printInitiatorType(entry);
    });
}

function printInitiatorType(perfEntry) {
  // Print this performance entry object's initiatorType value
  console.log(`… initiatorType = ${perfEntry.initiatorType ?? "NOT supported"}`);
}

Specifications

Specification
Resource Timing Level 2
# dom-performanceresourcetiming-initiatortype

Browser compatibility

BCD tables only load in the browser