The original question was: "Vanilla javaScript DOM queries. How to make sure async code has completed in front-end before continuing?"
but I changed the title, so that it would be more useful to search queries, and show what info is actually being given in the answer.
You'll notice that, based on the code that I provided, I thought that DOM manipulations were asynchronous. The answers pointed out that it is not.
If code like this is asynchronous:
let elements = document.querySelectorAll('div');
Then, how do you make sure that all of the 'div' elements have been stored to the variable 'elements' before looping over them?
let elements = document.querySelectorAll('div');
//how do you know that all of the elements will
//have been retrieved in time to run this for loop:
for(let i = 0 ; i < elements.length ; i++) {
let div = elements[i]; console.log(div);
}