Is it better to put the script tag in the head or body tag? 😕 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Is it better to put the script tag in the head or body tag? 😕

Javascript <script>

23rd Jul 2020, 4:14 PM
Trust Akalonu
Trust Akalonu - avatar
5 Answers
+ 6
The script put in head will be executed before in the body
23rd Jul 2020, 4:44 PM
Harsh
Harsh - avatar
+ 5
23rd Jul 2020, 5:05 PM
Gordon
Gordon - avatar
23rd Jul 2020, 4:28 PM
v@msi😉
v@msi😉 - avatar
+ 2
It's always better to place script tags just before the closing body tag..so that your html fully loads first and your js code get all the contents of your web page
24th Jul 2020, 9:12 AM
suvendu polley
suvendu polley - avatar
+ 1
I think its better in the body
23rd Jul 2020, 4:16 PM
Lexi Rockelle Smith
Lexi Rockelle Smith - avatar