Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do browsers process multiple javascript tags?

Does a browser process these two snippets the same way?:

    <script type="javascript">
     myFunction1();
     myFunction2();
    </script>

Vs.

<script type="javascript">
 myFunction1();
</script>
<script type="javascript">
 myFunction2();
</script>
like image 694
Blake Avatar asked Feb 12 '26 23:02

Blake


1 Answers

They will be absolutely equivalent. There are no scope differences, no execution differences, nothing.

The only difference is that there will be two instead of one script element in the parsed DOM.

like image 180
Pekka Avatar answered Feb 15 '26 13:02

Pekka