Performance of h5

I send a request using ajax, for example, I use a get request to request https://www.baidu.com/, and then I want to use the performance of h5 to get the timing,. When do I need to get the timing? Is the method to get timing written in the callback?

Mar.23,2021

performace is written on the window object automatically by the browser

so you only need to call window.performace.getEntries (), when the page is loaded, and you can get an array of all requests, and then find your baidu request object. Use the following method to get the time of the request

// 
function getEntryTiming (entry) {  
    var t = entry;
    var times = {};
 
    // 
    times.redirect = t.redirectEnd - t.redirectStart;
 
    // DNS 
    times.lookupDomain = t.domainLookupEnd - t.domainLookupStart;
 
    // 
    times.request = t.responseEnd - t.requestStart;
 
    // TCP 
    times.connect = t.connectEnd - t.connectStart;
 
    //  entry 
    times.name = entry.name;
    times.entryType = entry.entryType;
    times.initiatorType = entry.initiatorType;
    times.duration = entry.duration;
 
    return times;
}

look at http://www.alloyteam.com/2015.


get his series of parameters in the callback of success or failure

Menu