Last active
June 30, 2024 11:42
-
-
Save majido/596388beb38df8b46d02e5c61a65e065 to your computer and use it in GitHub Desktop.
A bookmarklet to add custom amount of jank to main thread. Crafted for those who π jank!
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
javascript:(function(){ | |
var meter = ` | |
<label style="position:fixed; z-index:10000; top: 0; left: 50%; transform: translateX(-50%); background-color: pink; padding: 5px;"> | |
Main thread jank (0-500ms): <input id="jankmeter" type="range" min=0 max=500 value=50> | |
</label> | |
`; | |
const d = document.createElement('jank'); | |
d.innerHTML = meter; | |
document.body.appendChild(d); | |
requestAnimationFrame(function jank() { | |
requestAnimationFrame(jank); | |
const range = document.querySelector('input[type=range]#jankmeter'); | |
const start = performance.now(); | |
while(performance.now() - start < range.value); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: Just add a bookmark with above text as its content.