Currently I am doing the below but bogging down the call-stack; how could I use perhaps an async
await
or newer promise functions to handle this better? I have a dynamic node that is added to the dom at different times due to various load times - instead of checking over and over again with something like the below, could I simply handle with an async
await
somehow?
function checkForNode() {
let coolNode= document.getElementById("CoolDomNode");
if (coolNode) {
doManyThings(coolNode);
} else {
checkForNode()
}
}