Skip to content

Instantly share code, notes, and snippets.

@travhimself
Last active December 23, 2016 15:42
Show Gist options
  • Select an option

  • Save travhimself/beb6da78fab760fab8010dbdeeb602fa to your computer and use it in GitHub Desktop.

Select an option

Save travhimself/beb6da78fab760fab8010dbdeeb602fa to your computer and use it in GitHub Desktop.
// search for a DOM element every rendering frame until it exists
//
// borrowed from:
// https://swizec.com/blog/how-to-properly-wait-for-dom-elements-to-show-up-in-modern-browsers/swizec/6663
function lookforelement() {
if ( !$('.element').size() ) {
window.requestAnimationFrame(lookforelement);
} else {
console.log('found element');
}
};
lookforelement();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment