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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:46:12+00:00 2026-06-04T13:46:12+00:00

This has not been answered here or there . These questions are poorly worded,

  • 0

This has not been answered here or there. These questions are poorly worded, and the answers are all along the lines of “use DOMReady”.

I want to ensure that code is run only if the page has finished loading. I cannot alter the HTML file itself, but if I could, I would do something that amounts to this:

<!DOCTYPE html>
<html>
  <head>
    <script>window.loaded=false;</script>
  </head>
  <body onload="window.loaded=true;">
    <!-- ... -->
  </body>
</html>

Then in my code:

if (window.loaded) { run(); }
else { document.addEventListener("load", run); }

And that would achieve exactly what I want. Unfortunately, I cannot modify the HTML, which means that I am looking for a way to determine whether the document has loaded (not if the DOM is ready) from JS code only.

I have looked around quite a bit, but so far, all I have found revolves around DOMReady. Has no-one really ever looked for this?

  • 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-04T13:46:14+00:00Added an answer on June 4, 2026 at 1:46 pm

    As Dr.Molle points out, document.readyState contains the property you’re after:

    document . readyState

    Returns "loading" while the Document is loading, "interactive" once it is finished parsing but still loading sub-resources, and "complete" once it has loaded.

    The readystatechange event fires on the Document object when this value changes.

    The order of event firing and readyState change is defined in the end of parsing section of the HTML5 spec. In summary:

    1. The document readyState is set to "interactive" as soon as parsing is complete.
    2. The DOMContentReady event is fired almost immediately (after it’s determined which resources need to be loaded).
    3. Those resources are loaded.
    4. The document readyState is set to "complete" and the load event is fired.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry if this has already been answered but I could not find it here.
I know this question has been partly answered here on S.O. , but there
I know this has been answered here before, however even after following all the
Maybe this has been answered before, but I was not able to find it.
I'm not sure if this has been answered yet, I looked at a couple
This has already been asked here , but I am just not satisfied with
i know this has already been asked here in stackoverflow, but i could not
I'm not sure if this question has been answered in full or if my
I'm not sure if this type of question has been answered before. In my
I realize that this question has been asked and has been answered here but

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.