+ 2

Where is better to include JavaScript in HTML. In tag Body or Head?

16th Jul 2018, 10:39 AM
CŠ»aŠ²eŠ½ Š‚ŠµŃ€Š²ŠøŠ“Š°
CŠ»aŠ²eŠ½ Š‚ŠµŃ€Š²ŠøŠ“Š° - avatar
3 Answers
+ 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
16th Jul 2018, 12:13 PM
CalviÕ²
CalviÕ² - avatar
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ā˜ŗļøā˜ŗļø.
16th Jul 2018, 10:46 AM
Meet Mehta
Meet Mehta - avatar
0
Thanks, I am beginner.šŸ˜Š
16th Jul 2018, 10:48 AM
CŠ»aŠ²eŠ½ Š‚ŠµŃ€Š²ŠøŠ“Š°
CŠ»aŠ²eŠ½ Š‚ŠµŃ€Š²ŠøŠ“Š° - avatar