+ 2
Where is better to include JavaScript in HTML. In tag Body or Head?
3 ответов
+ 3
Include in the head tag for JavaScript library that need to be loaded before could process by other scripts. eg jQuery, moment.js...
Include in body before closing body tag for scripts that need to render the DOM elements, eg. scripts that run getElementById, querySelector functions
0
At the top of end body tag.
Because its wait untill your html and css is rendered.
Thus making nice user interface.
Hope this helps☺️☺️.
0
Thanks, I am beginner.😊