Hey all. In this JavaScript lesson I’ll show you exactly where to put your JavaScript code. The code can essentially be placed anywhere on your HTML document, but good practise dictates that
you place it near the bottom of your code, and in an external file if it’s global or large.
SUBSCRIBE TO CHANNEL – https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg?sub_confirmation=1
========== JavaScript for Beginners Playlist ==========
========== CSS for Beginners Playlist ==========
========== HTML for Beginners Playlist ==========
========== The Net Ninja ============
For more front-end development tutorials & to black-belt your coding skills, head over to – https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg or http://thenetninja.co.uk
========== Social Links ==========
Twitter – @TheNetNinja – https://twitter.com/thenetninjauk
Original source
20 responses to “JavaScript Tutorial For Beginners #4 – Where to put your JS”
hey man look for the code so small with my eyes have a colapse
Hi I'm just a beginner and I'm just wondering if is this working on Xampp Server?
The alert is printing out before the site actually loads, I tested it out with opening the site again in a new tab so the cash does not have the site loaded already, you should test this out to and correct it in the video.
What is the div element
Clear and concise tuts with the added bonus of a northern accent.
I used "thenewboston" playlist first, so I know this. Guys, you CAN put your JS in the head OR in the body. However, it's usually better to put it in the bottom of the body so it all loads after the content since JS sometimes means intricate graphics/animation that go on the page and in such a case you want the framework to lay out first (the HTML). If you have a teacher who is going to test you, you go with what they say as long as they are your teacher because well, teachers mark off for stuff like that.
Fucking Wix Ads!!!
i was watching another tutorial of JavaScript and there, they say you should put your script in the head section.
which one should I do, which one is better so I won't have any problem with my codes in the future.
I'm really looking forward to an answer..
Although, I suppose, that if someone is creating a page that should only be accessed by someone of a certain age, then it's important to have the JS alert before the site content as to prevent the person of false/under age from seeing any content before agreeing to the age verification? I guess it depends but I actually understand this. I always prefer to have my JS external, just in case it gets big.
Hey hope your well, i have just come across your videos and i also find them very insightful. thank you and keep it up.
i am facing a problem
i need ur help plz
Thank you for these videos! I'm taking a web development class now (university level) and the prof. isn't very good! Now I'm not so lost, after watching your videos! thanks!
But can you put the script AFTER the body?
Your tutorials about Javascript are useful and easy to understand
thank you for sharing useful knowledge
you are an amazint tutor
Hey I am getting an errror
:
alert was used before it was defined
your simple and best
you give me hope!!!
thank you this helped me