<script type="text/javascript">
function chk(){
var ntime = performance.timing;
var total = ntime.loadEventEnd - ntime.navigationStart; //전체 소요시간
var redirect = ntime.redirectEnd - ntime.redirectStart; // 동일 origin에서의 redirect 시간
var cache = ntime.domainLookupStart - ntime.fetchStart; // cache 시간
var dnslookup = ntime.domainLookupEnd - ntime.domainLookupStart; //DNS Lookup 시간
var connect = ntime.connectEnd - ntime.connectStart; // 웹서버 연결 시간
var request = ntime.responseStart - ntime.requestStart; // 요청 소요 시간
var response = ntime.responseEnd - ntime.responseStart; // 응답 데이터를 모두 받은 시간
var dom = ntime.domComplete - ntime.domLoading; // DOM객체 생성 시간 *******************
var load = ntime.loadEventEnd - ntime.loadEventStart; // 브라우저의 Load 이벤트 실행시간
var pageEnd = ntime.loadEventEnd - ntime.responseEnd; // 서버에서 페이지를 받고 페이지를 로드하는데 걸린 시간
var networkDelay = ntime.responseEnd - ntime.fetchStart; // 네트워크 지연 시간
console.log("total : " + total + "ms >>>>>>> 전체 소요시간");
console.log("redirect : " + redirect + "ms >>>>>>> 동일 origin에서의 redirect 시간");
console.log("cache : " + cache + "ms >>>>>>> cache 시간");
console.log("dnslookup : " + dnslookup + "ms >>>>>>> DNS Lookup 시간");
console.log("connect : " + connect + "ms >>>>>>> 웹서버 연결 시간");
console.log("request : " + request + "ms >>>>>>> 요청 소요 시간");
console.log("response : " + response + "ms >>>>>>> 첫 응답으로 부터 응답 데이터를 모두 받은 시간");
console.log("dom : " + dom + "ms >>>>>>> DOM객체 로드 완료 시간");
console.log("load : " + load + "ms >>>>>>> 브라우저의 Load 이벤트 실행시간");
console.log("pageEnd : " + pageEnd + "ms >>>>>>> 서버에서 페이지를 받고 페이지를 로드하는데 걸린 시간");
}
</script>
자바스크립트 페이지 속도 체크 코드
[ Web 관련 ]자바스크립트카테고리의 다른글
자바스크립트에서 pdf 출력하기 (html2canvas + jspdf) (1) | 2019.06.24 |
---|---|
웹에서 파일 실행 exe, 실행파일 (0) | 2019.03.19 |
크롬에서 스크립트 오류 발생 - The message port closed before a response was received (0) | 2019.02.17 |
화면 중간에 팝업 띄우기 (0) | 2019.02.15 |
셀렉트박스 선택값 가져오기 (0) | 2018.12.26 |