Skip to content

Instantly share code, notes, and snippets.

@anandanand84
Forked from ebidel/firstpaint.js
Created June 27, 2016 21:36
Show Gist options
  • Save anandanand84/fc6777d38dd690841a4b54bf3f28da0e to your computer and use it in GitHub Desktop.
Save anandanand84/fc6777d38dd690841a4b54bf3f28da0e 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