Skip to content

Instantly share code, notes, and snippets.

@majido
Last active June 30, 2024 11:42
Show Gist options
  • Save majido/596388beb38df8b46d02e5c61a65e065 to your computer and use it in GitHub Desktop.
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!
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);
});
})();
@majido
Copy link
Author

majido commented Aug 28, 2018

Usage: Just add a bookmark with above text as its content.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment