DEV Community

Stanislav Vranic
Stanislav Vranic

Posted on

2

Document ready Vanilla JS

document.addEventListener("DOMContentLoaded", function() {

});
Enter fullscreen mode Exit fullscreen mode
var ready = (callback) => {
  if (document.readyState != "loading") callback();
  else document.addEventListener("DOMContentLoaded", callback);
}

ready(() => { 
  /* Custom JS */ 
});
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay