Skip to content

Instantly share code, notes, and snippets.

@calvinchoy
Last active April 4, 2020 08:37
Show Gist options
  • Save calvinchoy/0b449236ada00a21f4a3 to your computer and use it in GitHub Desktop.
Save calvinchoy/0b449236ada00a21f4a3 to your computer and use it in GitHub Desktop.
[JS - Get load time] Get server performance load time using javascript
function getLoadTime() {
var now = new Date().getTime();
// Get the performance object
window.performance = window.performance || window.mozPerformance || window.msPerformance || window.webkitPerformance || {};
var timing = performance.timing || {};
if (timing) {
var load_time = now - timing.navigationStart;
console.log('Load time: ' + load_time + 'ms');
}
}
window.onload = function() {
getLoadTime();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment