javascriptnavigation-timing-apiresource-timing-api

Can the NavigationTimingAPI be used on asynchronous calls?


I'm currently implementing performance measuring functionality in our project which uses custom elements v1.

The NavigationTimingAPI offers very detailed measuring on different navigation types (navigate, reload, browser back/forward):

enter image description here

Can the same (or similarly detailed) be made available for asynchronous calls as well? Or is there another API for that which I'm unaware of?

That is, when the page is fully loaded and some user interaction or event triggers a POST or GET on a server-located resource.

The only thing I found so far is setting measurepoints using performance.mark().

Did I miss something crucial here?


Solution

  • I missed the obvious here.

    Each XMLHTTPRequest with all the applicable details is automatically available as a PerformanceResourceTiming object in

    performance
      .getElementsByType("resource")
      .filter(function(x) { 
        return x.initiatorType === "xmlhttprequest";
      });
    

    I was looking into the performance.timing object only (actually the only thing not available via performance.getElementsByType()).