https://griddle-reviews.blogspot.com/2023/11/javascript-waiting-for-event-before.html
Javascript - Waiting For Event Before Proceeding