Last active
December 17, 2015 00:19
-
-
Save achudars/5520464 to your computer and use it in GitHub Desktop.
Get page load time via Javascript and jQuery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//calculate the time before calling the function in window.onload | |
var beforeload = (new Date()).getTime(); | |
function getPageLoadTime(){ | |
//calculate the current time in afterload | |
var afterload = (new Date()).getTime(); | |
// now use the beforeload and afterload to calculate the seconds | |
seconds = (afterload-beforeload) / 1000; | |
// Place the seconds in the innerHTML to show the results | |
$("#load_time").text('Page load time :: ' + seconds + ' sec(s).'); | |
} | |
window.onload = getPageLoadTime; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment