VN:F [1.9.22_1171]
Rating: 7.4/10 (16 votes cast)

This tutorial will show you how to display how to display time taken to load a webpage using javascript
First in the head section of the webpage you should add this code

<script type='text/javascript'>
var d = new Date();
var starttime = d.getTime();
</script>
<div id="loadtime"></div>

The above script will load the start time of the page.Now, we should define an endtime for the webpage.This can be achieved by defining the following javascript on the footer.

<script type='text/javascript'>
var d2 = new Date();
var endtime = d2.getTime();
var totaltime = (endtime - starttime)/1000;
var result = Math.round(totaltime*100)/100;
document.getElementById("loadtime").innerHTML = 'Page loaded in: ' + result +' seconds';
</script>
VN:F [1.9.22_1171]
Rating: 7.4/10 (16 votes cast)

Leave a Reply

Your email address will not be published. Required fields are marked *