What noticable difference is there?: placing script within the <head> as opposed to within the <body> | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What noticable difference is there?: placing script within the <head> as opposed to within the <body>

8th Mar 2019, 2:29 PM
Nabbacus
2 Answers
+ 5
Difference is only style and readable code... Now days css JavaScript used external link in modern website for better understanding..
8th Mar 2019, 2:51 PM
Scooby
Scooby - avatar
+ 4
The scripts in head run before body is loaded. Any attempts to retrieve DOM will return null. The scripts in end of body allows attempts to retrieve DOM, which in turn supports setting properties or event listeners to the DOM.
8th Mar 2019, 5:51 PM
Gordon
Gordon - avatar