Skip to content

Instantly share code, notes, and snippets.

@pocketbird
Last active July 3, 2017 17:21
Show Gist options
  • Save pocketbird/39687aa0e0a00896c3c2d8d7964cbac1 to your computer and use it in GitHub Desktop.
Save pocketbird/39687aa0e0a00896c3c2d8d7964cbac1 to your computer and use it in GitHub Desktop.
// Check if the DOM is ready every 100ms.
// If it is, clear the interval and do
// what you need to do inside the if statement
var isTheDomReady = setInterval(function() {
if (document.readyState === 'complete') {
clearInterval(isTheDomReady); // document ready, clear interval
// Do your stuff here.
}
}, 100);
// ES6
let isTheDomReady = setInterval(() => {
if (document.readyState === 'complete') {
clearInterval(isTheDomReady); // document ready, clear interval
// Do your stuff here.
}
}, 100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment