Skip to content

Instantly share code, notes, and snippets.

@JonasBa
Created February 25, 2024 14:54
Show Gist options
  • Save JonasBa/90a9ed25f11a6c186ec3e9905afeee9c to your computer and use it in GitHub Desktop.
Save JonasBa/90a9ed25f11a6c186ec3e9905afeee9c to your computer and use it in GitHub Desktop.
LoAF scripts attribution test
// go to chrome://flags/ and enable Experimental Web Platform features flag
// Add a logger for LoAF entries
const observer = new PerformanceObserver(function(list) {
for (const entry of list.getEntries()) { console.log(entry) }
});
observer.observe({type: "long-animation-frame", buffered: true});
// Define a slow and fast function. The slow function here is the precise source of our performance bottleneck
function slow(){
let start = performance.now()
while(performance.now() - start < 1e3){}
}
function fast(){
slow();
}
// Add fast() call somewhere in your UI, what does scripts attribute of the logged entry represent?
// Let me know at jonas.badalic@sentry.io or https://twitter.com/JonasBadalic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment