DEV Community

Cover image for How to Embed JavaScript in Your HTML ??

How to Embed JavaScript in Your HTML ??

Hrushikesh Kokardekar on July 31, 2021

How many of you like dynamic web pages ? Using HTML and CSS you can create and style static web page but you cannot perform actions on it. To make ...
Collapse
 
hrushikesh41 profile image
Hrushikesh Kokardekar

Surely will look into it 🙂

Collapse
 
aheisleycook profile image
privatecloudev

i just use external

Collapse
 
hrushikesh41 profile image
Hrushikesh Kokardekar

Yes that's preferable cause it helps to manage our files in a good manner

Collapse
 
aheisleycook profile image
privatecloudev

managing project files is key

Thread Thread
 
hrushikesh41 profile image
Hrushikesh Kokardekar

True!!

Thread Thread
 
aheisleycook profile image
privatecloudev

root
\assets\ -< css and and js and imgs go here
other files routing and databases

Collapse
 
kevincodemaster profile image
Kevin Ochieng

You could also nest the script tag in the header tag with a defer attribute for the script to be loaded last

Collapse
 
hrushikesh41 profile image
Hrushikesh Kokardekar

Yes

Collapse
 
juz14girl profile image
juz14girl • Edited

But how does the code looks like inside the separated js file? Sorry if I ask as I am really new to this. Thanks

Collapse
 
hrushikesh41 profile image
Hrushikesh Kokardekar

Don't be sorry. It's really nice to ask questions. You can see snip of my js file. In my upcoming post you will be more clear about the appearance of the code.

dev-to-uploads.s3.amazonaws.com/up...

Collapse
 
juz14girl profile image
juz14girl

Thank you so much! You're so kind. I'll be looking forward to that upcoming post!😊

Thread Thread
 
hrushikesh41 profile image
Hrushikesh Kokardekar

Sure. Will try to answer all your questions and explore you all to new topics 😊

Collapse
 
hrushikesh41 profile image
Hrushikesh Kokardekar

Yep external is always preferable