Javascript 导航定时API事件未按顺序触发

Javascript 导航定时API事件未按顺序触发,javascript,api,timing,navigation-timing-api,Javascript,Api,Timing,Navigation Timing Api,我正在使用导航计时API从页面获取加载事件。我在下面添加了JS片段以输出信息。我注意到一件奇怪的事情是,当我检查控制台时,loadEventEnd时间比loadEventStart时间来得早。我认为这是不可能的 var startTime = new Date().getTime(); // retrieve the performance object in a cross browser way. Check window.performance first. window.performa

我正在使用导航计时API从页面获取加载事件。我在下面添加了JS片段以输出信息。我注意到一件奇怪的事情是,当我检查控制台时,
loadEventEnd
时间比
loadEventStart
时间来得早。我认为这是不可能的

var startTime = new Date().getTime();
// retrieve the performance object in a cross browser way. Check window.performance first.
window.performance = window.performance || window.mozPerformance || window.msPerformance || window.webkitPerformance || {};
var timing = window.performance.timing || {};
var navigation = window.performance.navigation || {};

// if the Navigation Timing API is supported
if (window.performance && window.performance.timing) {
    pageRequestStart = timing.requestStart;
    pageResponseStart = timing.responseStart;
    pageResponseEnd = timing.responseEnd;
    pageLoadEventStart = timing.loadEventStart;
    pageLoadEventEnd = timing.loadEventEnd;
    pageLoadTime = timing.navigationStart;
}
var timingOutput =
    "requestStart: " + pageRequestStart + "\n"
    + "responseStart: " + pageResponseStart + "\n"
    + "responseEnd: " + pageResponseEnd + "\n"
    + "loadEventStart: " + pageLoadEventStart + "\n"
    + "loadEventEnd: " + pageLoadEventEnd + "\n"
    + "navigationStart: " + pageLoadTime;
console.log(timingOutput);

虽然我不确定你的案例的具体情况,但是IE、Chrome、Firefox和Opera都是全新的。在浏览器中开发规范和实现的过程中,由于浏览器之间的各种实现差异,出现了许多与上面描述的类似的小错误


您看到的bug可能已在最近的浏览器版本中修复。如果您在运行的浏览器上仍然一致地看到问题,您可以尝试查看是否有任何问题出现。

是一致地看到,还是只是一次性的?