A DOM mutation before DOMContentLoaded in its entirety

A small nuance-trivia question (with a nice secondary question):

Can there be a DOM mutation before DOMContentLoaded in its entirety?
Is there any problem based on such scenario?

Yes there can be.

Yes there can be. :slight_smile:
But, it all depends on what you are attempting to do.

I seek to learn about a “typical” or “very common” example for a case were the DOM is mutated before DOMContentLoaded is achieved.

I don’t recall ever coming across such a mutation so I seek some “oh yes it happened to me” example. :slight_smile:

One example is where you have a message on the page for when JavaScript is not enabled, which is immediately followed by a script that removes that message. The script runs, message no longer exists, and the DOM continues loading until you get to the DOMContentLoaded event.

Thank you.

If JavaScript was turned off, why would it be important to remove this message?

If JavaScript was turned off, the attempt to remove it doesn’t occur because that attempt requires JavaScript in order to do so.


Well than, sadly, I misunderstood the example… :frowning:
I tried reading it three times but didn’t understand it. :frowning:

Here is the sample code:

<div id="nojavascript">This page sadly doesn't work without JavaScript</div>

When there is JavaScript. that scripting code runs and removes the message.

When there isn’t any JavaScript that scripting code cannot run, resulting in the message remaining.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.