Skip to content

Instantly share code, notes, and snippets.

@thewarpaint
Last active June 9, 2016 21:12
Show Gist options
  • Save thewarpaint/8a9832984c167cde0f6484bac337b04a to your computer and use it in GitHub Desktop.
Save thewarpaint/8a9832984c167cde0f6484bac337b04a to your computer and use it in GitHub Desktop.
window.performance.timing
(function() {
var timingKeys = ['connectEnd', 'connectStart', 'domComplete', 'domContentLoadedEventEnd', 'domContentLoadedEventStart',
'domInteractive', 'domLoading', 'domainLookupEnd', 'domainLookupStart', 'fetchStart', 'loadEventEnd', 'loadEventStart',
'navigationStart', 'redirectEnd', 'redirectStart', 'requestStart', 'responseEnd', 'responseStart', 'unloadEventEnd',
'unloadEventStart'];
timingKeys
.map(function (key) {
return {
key: key,
value: window.performance.timing[key]
};
})
.sort(function (a, b) {
if(a.value > b.value) {
return 1;
}
if(a.value < b.value) {
return -1;
}
return 0;
})
.forEach(function (metric) {
console.log(metric.key + ' at ' + metric.value);
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment