Skip to content

Instantly share code, notes, and snippets.

@leMaur
Forked from davidgilbertson/logTimes.js
Created July 27, 2017 07:10
Show Gist options
  • Save leMaur/1d2d7b4e6b5c470d3a5cb1e1534c93a3 to your computer and use it in GitHub Desktop.
Save leMaur/1d2d7b4e6b5c470d3a5cb1e1534c93a3 to your computer and use it in GitHub Desktop.
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