you can apply event listeners after that HTML code is parsed to the DOM (a.k.a. loaded)
you can also apply event listener to the root of where that HTML is appended and utilize event delegation (so no need wait for HTML to be parsed)
https://davidwalsh.name/event-delegate
it should be fine to add event listeners after this line
side question: why do you have init
function marked as async
? you don't use await
there
about buttons you want to add event listeners to
// I want to add click events on button1 and button2
if i found "buttons" you are talking about, then they are not buttons, but divs, which is a bad approach to pick
these should be