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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:08:06+00:00 2026-05-26T19:08:06+00:00

The question is so like a zillion others here and on the web –

  • 0

The question is so like a zillion others here and on the web – How to check if DOM has loaded in Javascript? But here’s the catch:

  • Without using a framework like jQuery etc;
  • Without knowing if your script has been loaded via a statically placed <script> tag or via some other Javascript much later after the DOM has already loaded.

Can this be done more or less reliably and with cross-browser compatibility?

Added: Let me clarify: I’m writing a standalone .JS file which can be included in arbitrary webpages. I want to execute code AFTER the DOM has been loaded. But I don’t know HOW my script will be included. It could be by placing a <script> tag (in which case the traditional onload or DOM-readiness solutions will work); or it could be loaded via AJAX or some other means, much later after the DOM is already loaded (so the previously mentioned solutions will never fire).

  • 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-05-26T19:08:07+00:00Added an answer on May 26, 2026 at 7:08 pm

    The document.readyState property can be used to check if the document is ready. From MDN:

    Values

    The readyState of a document can be one of following:

    • loading – The document is still loading.
    • interactive – The document has finished loading and the document has been parsed but sub-resources such as images, stylesheets and frames are still loading.
    • complete – The document and all sub-resources have finished loading. The state indicates that the load event is about to fire.

    Code example:

    if(document.readyState === "complete") {
        // Fully loaded!
    }
    else if(document.readyState === "interactive") {
        // DOM ready! Images, frames, and other subresources are still downloading.
    }
    else {
        // Loading still in progress.
        // To wait for it to complete, add "DOMContentLoaded" or "load" listeners.
    
        window.addEventListener("DOMContentLoaded", () => {
            // DOM ready! Images, frames, and other subresources are still downloading.
        });
    
        window.addEventListener("load", () => {
            // Fully loaded!
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have simllar question like here: static-method-invocation , but in PHP. Simply, I want
More or less the same question like here, but right align: HorizontalAlignment=Stretch, MaxWidth, and
A question like this has been asked differently several times. Yet here i am.
Dear all, the question like this one has been already asked , but among
It's quite possible a question like this has been asked before, but I can't
First of all there is probably a question like this already but i couldn't
I have searched stackoverflow for a question like mine but most of the questions
I have a similar, but different, question like How to redirect Powershell output from
My question is like this: Reordering UITableView without reorder control , I use these
I've asked a question like this before but this one is different, this is

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.