0

Why do we use Javascript in HTML?

16th Dec 2017, 10:35 AM
Yash Robin
Yash Robin - avatar
9 Answers
+ 6
For interactivity and responsiveness. It makes webpages dynamic and not static
16th Dec 2017, 10:43 AM
Koketso Dithipe
Koketso Dithipe - avatar
+ 5
if you use that script for multiple pages, or u use famous libraries, use the src, cuz it can avoid user form loading the script multiple times, as they may have already loaded the script previously in another page that use the same script.
16th Dec 2017, 12:48 PM
EnRico Lam
EnRico Lam - avatar
+ 3
because we can, so we do
16th Dec 2017, 10:50 AM
EnRico Lam
EnRico Lam - avatar
+ 3
...heck, he ask why, not how... @Morpheus, read the question first
16th Dec 2017, 12:44 PM
EnRico Lam
EnRico Lam - avatar
+ 3
it depends, if your script is going to be used for one specific page, use the <script></script> method
16th Dec 2017, 12:46 PM
EnRico Lam
EnRico Lam - avatar
+ 2
keeping script in same html file is better , as it would take one less http request , so 2 is better, but when files get very big and complicated it's better to put separate JavaScript file and use src
16th Dec 2017, 12:49 PM
Morpheus
Morpheus - avatar
+ 1
thanks Samaritan and mine storm
16th Dec 2017, 10:52 AM
Yash Robin
Yash Robin - avatar
+ 1
Thanks you Very Much😊 Morpeus and Mine storm
16th Dec 2017, 12:50 PM
Yash Robin
Yash Robin - avatar
0
which is best ? 1.<script src="link to .js file"> in head tag or 2.<script> your JavaScript code </script>
16th Dec 2017, 12:37 PM
Yash Robin
Yash Robin - avatar