Skip to content

Instantly share code, notes, and snippets.

@jasonhwest
Created July 23, 2017 18:55
Show Gist options
  • Save jasonhwest/6597e1f11a56ab797618a24880a95ae0 to your computer and use it in GitHub Desktop.
Save jasonhwest/6597e1f11a56ab797618a24880a95ae0 to your computer and use it in GitHub Desktop.
// https://hackernoon.com/measuring-web-performance-its-really-quite-simple-adeda8f7f39e
function logTimes(message) {
performance.mark(message); // this one is for WebPageTest
console.timeStamp(message); // this is for the Performance tab in Chrome DevTools
console.info(message, performance.now()); // this is for the console, duh
// this here is for Google Analytics
ga('send', {
hitType: 'timing',
timingCategory: 'Performance',
timingVar: message,
timingValue: performance.now(),
});
}
// use it like so
bindAllMyEventsOrWhateverGetsThePageReady();
logTimes('The page is really ready');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment