JSFiddle - React, Tailwind, and code Playground
JavaScript
// prepare the XHR object
$.ajax({
beforeSend: function(){
// right before firing off the request, create a global object that includes the request send time
window.startTime = new Date();
},
// send the request to the root URI of this host
url: '/',
success: function(){
// once the request comes back, record the end time
window.endTime = new Date();
// take the difference, which will yield a number in milliseconds, and print it out
document.write(window.endTime - window.startTime + " ms");
}
})