Warten Sie, bis das DOM JavaScript lädt

document.addEventListener('DOMContentLoaded', (event) => {
  //the event occurred
})
Breakable Bison