Skip to content

Instantly share code, notes, and snippets.

@mmocny
Created April 14, 2023 14:12
Show Gist options
  • Save mmocny/40714c2ee3851fd765765fd8a3674c28 to your computer and use it in GitHub Desktop.
Save mmocny/40714c2ee3851fd765765fd8a3674c28 to your computer and use it in GitHub Desktop.
Add these snippets to DevTools (console) Watch expressions
// max-INP:
(()=>{let o=globalThis;return void 0===o.winp&&(o.winp=0,new PerformanceObserver(n=>{for(let e of n.getEntries()){if(!e.interactionId)continue;o.winp=Math.max(e.duration,o.winp);let r=o=>o<=200?"color: green":o<=500?"color: yellow":"color: red";console.log(`%c[Interaction: ${e.name.padEnd(12)}] %cDuration: %c${e.duration}`,"color: grey; font-family: Consolas,monospace","",r(e.duration))}}).observe({type:"event",durationThreshold:0,buffered:!0})),o.winp})();
// interactionCount
performance.interactionCount;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment