ajaxxmlhttprequestload-time

ajax get xmlHttpRequest load time


Is there a way to get an xmlHttpRequest load time?

Otherwise I'll have to set a function that count it, so?


Solution

  • To the best of my knowledge there isn't an execution time included as part of the XMLHTTPRequest object. You can, however, use JS to calculate this value:

    const start = Date.now();
    
    // Execute request
    
    alert( "Request took: " + ( Date.now() - start ) );

    For more info on the data that is stored in the XMLHTTPRequest object, see this page.