JavaScript 2025 · DOM and browser

Run code when the page is ready

Wait for the HTML to be parsed. Scripts with defer or type=module don't need this.

document.addEventListener("DOMContentLoaded", () => {
  init();
});

Official JavaScript 2025 documentation

More dom and browser commands

All dom and browser commands · JavaScript 2025 cheatsheet

Was this page helpful?