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 7906085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:46:17+00:00 2026-06-03T10:46:17+00:00

I have a web page whose large parts are constructed on the front-end, in

  • 0

I have a web page whose large parts are constructed on the front-end, in JavaScript. When the basic HTML is parsed and the DOM tree is constructed, the "ready" event triggers. At this event, a JavaScript code launches that continues with the construction of the web page.

$().ready(function() {
    $(document.body).html('<img src = "img.png" />');
    $.ajax({
        url: 'text.txt'
    });
});

As you can see in this tiny example,

  • new elements are added to DOM
  • more stuff, like images is being loaded
  • ajax requests are being sent

Only when all of this finishes, when the browser’s loading progress bar disappears for the first time, I consider my document to be actually ready. Is there a reasonable way to handle this event?

Note that this:

$().ready(function() {
    $(document.body).html('<img src = "img.png" />');
    $.ajax({
        url: 'text.txt'
    });
    alert('Document constructed!');
});

does not suffice, as HTTP requests are asynchronous. Maybe attaching handlers to every single request and then checking if all have finished is one way to do what I want, but I’m looking for something more elegant.

Appendix:
A more formal definition of the event I’m looking for:

The event when both the document is ready and the page’s dynamic content finishes loading / executing for the first time, unless the user triggers another events with mouse moving, clicking etc.

  • 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-03T10:46:19+00:00Added an answer on June 3, 2026 at 10:46 am

    As described here, you can sign up for load events for individual images when they finally load. However, as also described there, that may not be reliable across browsers or if the image is already in the browser’s cache. So I think at least part of that is not 100% trustworthy. With that said, you can easily hook to a bunch of different asynchronous events and then only react when all of them have completed. For example:

    $(document.body).html('<img src="img.png" id="porcupine"/>');
    
    var ajaxPromise1 = $.get(...);
    var ajaxPromise2 = $.get(...);
    var imgLoadDeferred1 = $.Deferred();
    
    $("#porcupine").load(
      function() {
        imgLoadDeferred1.resolve();
      }
    );
    
    $.when(ajaxPromise1, ajaxPromise2, imgLoadDeferred1).done(
      function () {
        console.log("Everything's done.");
      }
    );
    

    If you want to allow for the fact that the image load may never generate an event, you could also set a timer which would go off eventually and try to resolve the imgLoadDeferred1 if it is not already resolved. That way you don’t get stuck waiting for an event that never happens.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to call a web service from Javascript of a html page whose
I have a text box on a web page, whose value I want to
I have an anchor tag on an ASP.NET page, whose text (inner HTML) I
I have a web content form whose master page is a nested master page.
I have a web page that I created with html tags(form and table) and
I have a web page whose content I'd like to download into a wxString.
Here's what I have: A web application that runs in a single HTML page
I have a web page (SSL) that contains a barely visible iframe whose source
I have web page in PHP which displays all records in a table. I
I have web page which is passing a querystring parameter to page 2: <a

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.