riix
7/24/2012 - 6:58 AM

페이지 로드 시간 얻기, Get Page Load Time

페이지 로드 시간 얻기, Get Page Load Time

var beforeload = (new Date()).getTime(); // calculate the time before calling the function in window.onload

function getPageLoadTime() {
	var afterload = (new Date()).getTime(); // calculate the current time in afterload
	seconds = (afterload - beforeload) / 1000; // now use the beforeload and afterload to calculate the seconds
	console.log('Page load time :  ' + seconds + ' sec(s).'); // Place the seconds in the innerHTML to show the results
}

window.onload = getPageLoadTime;