0
Why do we use Javascript in HTML?
9 Answers
+ 6
For interactivity and responsiveness.
It makes webpages dynamic and not static
+ 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.
+ 3
because we can, so we do
+ 3
...heck, he ask why, not how...
@Morpheus, read the question first
+ 3
it depends, if your script is going to be used for one specific page, use the <script></script> method
+ 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
+ 1
thanks Samaritan and mine storm
+ 1
Thanks you Very Muchđ Morpeus and Mine storm
0
which is best ?
1.<script src="link to .js file"> in head tag
or
2.<script>
your JavaScript code
</script>