Last active
April 4, 2020 08:37
-
-
Save calvinchoy/0b449236ada00a21f4a3 to your computer and use it in GitHub Desktop.
[JS - Get load time] Get server performance load time using javascript
This file contains 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
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