where should i put js code? can it be a part of html doc, using tag <script>? or should it be written as stand-alone file and get linked to html using <link> in head? can u give an example plz? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

where should i put js code? can it be a part of html doc, using tag <script>? or should it be written as stand-alone file and get linked to html using <link> in head? can u give an example plz?

10th Sep 2016, 12:38 PM
Станислав Панченко
Станислав Панченко - avatar
4 Answers
+ 7
You also use <script> to link to a separate js file, not <link>. You can do one or the other. Using a separate file is usually a good idea. It can even be cached by the browser, which is useful if you use the same js file in different html pages. <script> //your javascript code here </script> <script src="path/to/your/external_script.js"></script>
10th Sep 2016, 12:46 PM
Zen
Zen - avatar
+ 2
the world enginers computer advice to put js code before body closing tag like the <script></script></body> cuz it will let ur page load
11th Sep 2016, 2:02 PM
mhennaoui
mhennaoui - avatar
+ 2
помогите
12th Sep 2016, 6:51 AM
Oxun Mamajonov
Oxun Mamajonov - avatar
0
v
2nd Nov 2016, 7:32 PM
юрій боліновський
юрій боліновський - avatar