Last active
June 6, 2018 11:43
-
-
Save zanonnicola/fa7374d218751bb498c9a7e2eaf14759 to your computer and use it in GitHub Desktop.
JS Helper functions - Fire function when browser is free
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
const deBounced = debounce(() => { | |
// The RAF ensures it doesn't run when tab isn't visible | |
requestAnimationFrame(() => { | |
// the RIC makes sure the browser isn't busy with something | |
// timeout: max amount of time to wait. | |
requestIdleCallback(fn(), { timeout: 500}) | |
}) | |
}, 30000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment