Vanilla JavaScript equivalent of jQuery's $.ready()

March 23, 2024

jQuery's $.ready() function is used to execute a function when the DOM is fully loaded. The equivalent in vanilla JavaScript is to use the DOMContentLoaded event.

document.addEventListener('DOMContentLoaded', function(){ 
    // your code goes here
}, false);

Made it this far? Have a go at the game of snake