Skip to content

Instantly share code, notes, and snippets.

@zanonnicola
Last active June 6, 2018 11:43
Show Gist options
  • Save zanonnicola/fa7374d218751bb498c9a7e2eaf14759 to your computer and use it in GitHub Desktop.
Save zanonnicola/fa7374d218751bb498c9a7e2eaf14759 to your computer and use it in GitHub Desktop.
JS Helper functions - Fire function when browser is free
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