Here's what happens when a browser loads a website with a <script>
tag on it:
- Fetch the HTML page (e.g. index.html)
- Begin parsing the HTML
- The parser encounters a
<script>
tag referencing an external script file. - The browser requests the script file. Meanwhile, the parser blocks and stops parsing theβ¦
Top comments (1)
It depends. Scripts in the head will load before the body and are counted as highest priority. You can see this in the network tab of devtools assuming you have enabled displaying of this metric. Scripts in the body are low priority. So if your content absolutely depends on the script to display the page I would consider my options carefully. Scripts in head are blocking and will prevent load of other assets bellow the fold (the body).