Page load time counter in JS
What I would like to see on websites is a little counter of the page load time placed in the footer, so I decided to share you the little piece of code in order to easily integrate this counter in your website footer.
ES5 Version (Older browsers)
(function () {
var time = window.performance && performance.timing;
if (time) {
var load = (time.loadEventEnd - time.navigationStart) / 1e3;
alert("This page loaded in " + load + " seconds");
}
})();
ES6 Version (Modern browsers)
(() => {
const time = window.performance && performance.timing;
if (time) {
const load = (time.loadEventEnd - time.navigationStart) / 1e3;
alert(`This page loaded in ${load} seconds`)
}
})();