I observed that there is a generic behavior to declare the javascript within head tag of HTML followed by the body and rest of the content. This is mostly practiced when we have jQuery or any other library files that we want to refer in our project,
Why do we need to add the javascript in the head tag of the HTML?
and
What difference would it make, If we add it within the body tag, whether there will be any change in page rendering performance of the browser?
For instance, I would like to understand following scenario. Consider my javascript contains following one line,
$(SomeHTMLTag).replace("%data%, NewName);
Now, if I add this javascript in a header tag, my HTML page will be rendered with newName.
Secondly, if I add javascript at the end of HTML after SomeHTMLTag has been rendered, then in such case whether there would be a duplication of rendering SomeHTMLTag with default name first and then with the new name?