
Đang tính thời gian tải trang...
HTML
Dán đoạn code bên dưới vào nơi muốn hiển thị thời gian tải trang<div id="load-time">Đang tính thời gian tải trang...</div>
Script
<script>
var showTime = document.getElementById('load-time'),
startTime = (new Date()).getTime(); // Get the time before `window.onload`
window.onload = function() {
// Get the current time in `window.onload`
var endTime = (new Date()).getTime();
// Now use the `startTime` and `endTime` to calculate the seconds
// And show the result inside `#load-time`
showTime.innerHTML = "Thời gian tải trang: " + ((endTime-startTime)/1000) + " giây(s).";
};
</script>