Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save achudars/5520464 to your computer and use it in GitHub Desktop.
Save achudars/5520464 to your computer and use it in GitHub Desktop.
Get page load time via Javascript and jQuery
//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