Order of html script

Asked 2 years ago, Updated 2 years ago, 45 views

The first thing that exists in the head tag for the execution order of the script statement is executed

After that, I thought it would be executed in the order of body tags.

However, when I tested it as below today, it was printed in the order of Warning 1-> Warning 2-> Warning 3, and p-tag output (I'm not sure if it's running at the same time or one of the two is running first) -> Warning 4-> Warning 5.

If my knowledge is correct,

Warning 1 -> ptag output -> Warning 2 -> Warning 3 -> Warning 4 -> Warning 5 seems correct, but I'm not sure why.

Why is this happening?

<!DOCTYPE html>

  <script>
    alert('11111111')
  </script>

</head>

<body>
    <p> Order is Warning 1 -> output ptag -> Warning 3 -> Output 4 in order </p>
  <script>alert('222222') </script>
  <script>alert('333333') </script>
  <script>alert('444444') </script>
  <script>alert('555555') </script>
</body>

</html>

html5 javascript

2022-09-21 15:23

1 Answers

I think it's only in Chrome browser. It's printed as you thought on other browsers. I think it would be good to learn about the Chrome browser domrender. We recommend you ask the Stack Overfloor or JavaScript Developer Forum. I don't know either...

Firefox 57.0.2

IE 11


2022-09-21 15:23

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.