-
-
Save xnimorz/917a57c624a24923dee002be5edce24d to your computer and use it in GitHub Desktop.
FMP 2 try
This file contains 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
// Запланировали отрисовку | |
requestAnimationFrame(function() { | |
// кадр еще не отрисовался, но рендер три в этот момент доступно | |
var renderTreeFormed = performance.now(); | |
// После этого raf кадр отрисовался | |
requestAnimationFrame(function() { | |
var fmp = performance.now(); | |
// Если страница была неактивна — не сохраняем эти данные | |
if (!window.globalVars.performance.pageWasActive) { | |
return; | |
} | |
window.globalVars.performance.fmp.push({ | |
renderTreeFormed: renderTreeFormed, | |
fmp: fmp | |
}) | |
}); | |
}); |
This file contains 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
window.globalVars.performance.pageWasActive = document.visibilityState === "visible"; | |
document.addEventListener("visibilitychange", function(e) { | |
if (document.visibilityState !== "visible") { | |
window.globalVars.performance.pageWasActive = false; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment