Why isn't Dave putting his <script> tags at the end of the body?
We have been taught to put <scipt> tags at the end of our body tags, am i missing something?
James ChurchillTreehouse Teacher
Knowing where to put
<script> tags can be a bit tricky. One of the advantages of putting
<script> tags just before the closing
<body> tag, is that you know you can safely access other elements on the page, without having to write any extra code.
Unfortunately, there are downsides to this approach. For a detailed overview of the various options that exist (including the new
<script> tag attributes), check out this community post:
Jason AndersTreehouse Moderator 144,856 Points
While it is often Best Practice to include the JS script files at the end of the HTML, there are many times where this might actually break the site instead.
I hope that helps clear it up.