-
-
Save anandanand84/fc6777d38dd690841a4b54bf3f28da0e to your computer and use it in GitHub Desktop.
Helper to print first paint time in Chrome
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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