Last active
March 3, 2026 11:08
-
-
Save gkucmierz/fc357ce424bf809a3d378a3a32d83cd4 to your computer and use it in GitHub Desktop.
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
| const lagDetector = (() => { | |
| let run = true; | |
| const TRESHOLD = 1e3/60 + 1; // ~60 FPS | |
| let lastTime = +new Date(); | |
| (function loop() { | |
| const time = +new Date(); | |
| const diff = time - lastTime; | |
| if (diff > TRESHOLD) { | |
| console.log(`Interface blocked for ${diff}ms`); | |
| } | |
| lastTime = time; | |
| run && setTimeout(loop, 1); | |
| })(); | |
| return { stop: () => run = false }; | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment