MaximPro
MaximPro

Reputation: 542

when the script abrupts another script

WHATWG spec has interesting step in prepare the script element algorithm:

Otherwise, immediately execute the script element el, even if other scripts are already executing.

What is that case? How does one script may pause of executing another script?

Upvotes: 3

Views: 87

Answers (1)

Bergi
Bergi

Reputation: 665344

Given the constraints, it's a script that is not a module, does not have a src attribute, and is inserted during a script execution. I think the following example qualifies:

<script>
console.log("before");
document.write(`<script>
console.log("nested");
<\/script>`);
console.log("after");
</script>

Upvotes: 3

Related Questions