My question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

My question

Should I insert JavaScript into HTML, or should I use it’s own section?

9th Nov 2019, 9:39 PM
Himanboy 1
Himanboy 1 - avatar
4 Answers
+ 4
You can create own js file and include in Html.
9th Nov 2019, 9:41 PM
A͢J
A͢J - avatar
+ 2
You should use it in a different file, unless your js code isn't too big/complex.
11th Nov 2019, 8:56 AM
US⚙️
US⚙️ - avatar
+ 1
I think. You should separate html,css,javascript and php etc. code. Because If you separate them, readability will be increased. There is example following: https://stackoverflow.com/questions/43717405/separate-html-javascript
9th Nov 2019, 10:36 PM
Hamza Yoğurtcuoğlu
Hamza Yoğurtcuoğlu - avatar
+ 1
Hamza Yoğurtcuoğlu You are linking to something with a downvote that doesn't inspire confidence. HTML and PHP can be intertwined together inside a php file. Sometimes Javascript is better in the same html page to be executed after the DOM loads. Separation of css and js from html is definitely convenient and that's what I do, but that is not the case all the time.
9th Nov 2019, 11:26 PM
Xyenia 🦉
Xyenia 🦉 - avatar