Created
October 25, 2023 16:28
-
-
Save Exponential-Workload/24a35c012669ed4dda881fe9173c1ec0 to your computer and use it in GitHub Desktop.
Force High-Performance
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
// FHP - Force High Performance (Mode) | |
// Demands that your browser renders frames constantly, triggering a higher-performance render | |
let fps = 0; | |
let lastT = 0; | |
let mounted = false; // if in sveltekit, set this to true onMount(), and false onDestroy()! | |
const animLoop = (t) => { | |
t = t / 1000; | |
if (lastT !== 0) { | |
fps = 1 / (t - lastT); | |
} | |
lastT = t; | |
if (mounted) requestAnimationFrame(animLoop); | |
}; | |
requestAnimationFrame(animLoop); // if in sveltekit, put this in your onMount! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment