JavaScript Tutorial For Beginners #4 – Where to put your JS




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”

  1. 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.

  2. 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.

  3. 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..

  4. 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.

Leave a Reply