Easy way to run javascript code after the DOM has been full loaded

Easy way to run javascript code after the DOM has been full loaded

Nov 22,2022

Sometimes you need the browser to execute javascript code when the DOM is full loaded because running them before would break the website or you just need to make the browser show the user some content and load the remaining after.

Whatever the reason you need this here is how you can achieve it:

With Pure Javascript:

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

  // Your code goes here

});

With JQuery:

// Be sure to include jquery library somewhere before this

$(document).ready(function() {

    // Your code goes here

});