Skip to content

$(document).ready() equivalent in JavaScript

In jQuery $(document).ready() function is used to execute a code block before the page contents are loaded. This can be achieved using the plain JavaScript like:

 var loader = setInterval(function () {
            if(document.readyState !== "complete") return;
            clearInterval(loader);
            alert("Document loaded!");
         }, 300);
See also  4Sum - Leetcode Challenge - Python Solution

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.