Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8587021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:27:50+00:00 2026-06-11T22:27:50+00:00

To make sure a document is ready before doing stuff, i do the following

  • 0

To make sure a document is ready before doing stuff, i do the following :

(function() {
    var interval = window.setInterval(function() {
        if("complete" === document.readyState) {
            window.clearInterval(interval);
            // Some stuff
        }
    }, 10);
})();

If somewhere in my code i create an image from JavaScript like this :

var image = new Image();
image.onload = function() {
   // Some other stuff
};
image.src = 'some_url';

Will the check I perform on document.readyState also wait for “image” to be loaded, or will it just wait for the images present in the HTML code, and only those, to be loaded ?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:27:51+00:00Added an answer on June 11, 2026 at 10:27 pm

    You don’t need your setInterval.

    From the MDN :

    The load event fires at the end of the document loading process. At
    this point, all of the objects in the document are in the DOM, and all
    the images and sub-frames have finished loading.

    You can simply do this for the statically included images :

    window.onload = function() {
        // Some stuff
    };
    

    As this doesn’t take into account the images you create later, you may do this :

    window.onload = function() {
        var image = new Image();
        image.onload = function(){
            // Some stuff
        };
        image.src = 'some_url';
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do make sure that my $(document).ready( function() { ... } ) block executes?
I cannot find a way to make sure the function is complete before checking
I have the following code that I apply when the document is ready: $(document).ready(function
My javascript: function onYouTubePlayerReady() { playerObj = document.getElementById(player_embed); playerObj.addEventListener(onStateChange, test); // Make sure the
Here is the script: var currentCat = all; $(document).ready(function(){ $(.categoryItem).click(function(event){ $(#browseBookArea).fadeToggle(100); currentCat = $(this).attr(id);
How can I make sure that the window doesn't close before the form is
What are differences between $(document).ready(function(){ //my code here }); and $(window).load(function(){ //my code here
I have the following code: <a href=http://mydomain.com/link123 class=someClickEvent>Some Link</a> $(document).ready(function(){ $('.someClickEvent').click(function() { var $deal_id
I'm trying to make sure that my JQuery ready function is working. In the
I have this Jquery: $(document).ready(function() { $('#masterChecks input[type=checkbox]').click(function() { var togClass=$(this).attr('class'); if($(this).attr('checked')){ //need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.