Skip to content

Instantly share code, notes, and snippets.

@ebidel
Last active January 15, 2018 07:55
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ebidel/1041c7ac4f6802034d27 to your computer and use it in GitHub Desktop.
Save ebidel/1041c7ac4f6802034d27 to your computer and use it in GitHub Desktop.
Helper to print first paint time in Chrome
(function() {
'use strict';
// First paint perf.
if (window.chrome && window.chrome.loadTimes) {
const getFP = function() {
let load = chrome.loadTimes();
let fp = (load.firstPaintTime - load.startLoadTime) * 1000;
return Math.round(fp);
};
window.onload = e => {
let render = () => {
let fp = getFP();
console.log(`${fp} ms`);
document.title += ' - ' + fp + ' ms fp';
};
window.setTimeout(render, 100); // Wait a tick so we're guaranteed a fp time.
};
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment