0

What is the non-jQuery equivalent of '$(document).ready()'?

JavaScript
function domReady(fn) {
  // If we're early to the party
  document.addEventListener("DOMContentLoaded", fn);
  // If late; I mean on time.
  if (document.readyState === "interactive" || document.readyState === "complete" ) {
    fn();
  }
}

domReady(() => console.log("DOM is ready, come and get it!"));
RUN
add comment
Suggest a different solution or add another example