How to know wheter DOM was already loaded or not?

How to know wheter DOM was already loaded or not?

I plan to provide a JS code that each website admin could decide how/when to run, so an admin may want to add my JS code to be loaded with the page, or may decide to load it later once the DOM has already been loaded.

So my JS code can not rely on the $().ready method because in the later case the code placed there would not be executed.

So I plan to set my logic into a "private" _run() method, and tell the website admin that he must execute the "public" run() method. Within run() method I need to know whether the DOM was already loaded or not:

- If the DOM is not yet loaded, then run() would do:

    jQuery(document).ready(function() { _run(); });


- Otherwise:

    _run();


Then I need a way to know whether the DOM was already loaded or not. Is there any way?

Thanks a lot.