Navigation Timing API를 사용하여 페이지에서로드 이벤트를 가져옵니다. 정보를 출력하기 위해 JS의 스 니펫을 추가했습니다. 내가 이상하다는 것을 알게 된 한가지는 loadEventEnd
시간이 콘솔을 확인할 때 loadEventStart
시간보다 빨리 되돌아 왔음을 알 수 있습니다. 나는 그것이 가능해서는 안된다고 생각합니다. 나는이 사건의 세부 사항의 확실하지 않다 동안탐색 타이밍 API 이벤트가 순서대로 실행되지 않습니다.
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);
일관되게 그런가요 아니면 일회용 이었습니까? –