Skip to content

Instantly share code, notes, and snippets.

@Exponential-Workload
Created October 25, 2023 16:28
Show Gist options
  • Save Exponential-Workload/24a35c012669ed4dda881fe9173c1ec0 to your computer and use it in GitHub Desktop.
Save Exponential-Workload/24a35c012669ed4dda881fe9173c1ec0 to your computer and use it in GitHub Desktop.
Force High-Performance
// 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