Skip to content

Instantly share code, notes, and snippets.

@danreeves
Created February 10, 2015 11:58
Show Gist options
  • Save danreeves/be1ef42b95c3c006144b to your computer and use it in GitHub Desktop.
Save danreeves/be1ef42b95c3c006144b to your computer and use it in GitHub Desktop.
Times the page load. Taken from http://timkadlec.com/
window.onload = function(){
setTimeout(function(){
window.performance = window.performance || window.mozPerformance || window.msPerformance || window.webkitPerformance || {};
var t = performance.timing || {};
if (!t) {
//fail silently
return;
}
var start = t.navigationStart,
end = t.loadEventEnd
loadTime = (end - start) / 1000;
var copy = document.getElementsByClassName('copy');
copy[0].innerHTML += "<span class='loaded'>This page loaded in <strong>" + loadTime + " seconds</strong>.</span>";
}, 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment