1.3 JavaScript in Browsers

So now we are ready to write our first JavaScript code. We need a script element, there are 2 places where we can add a script element, in the "Head" tag. Or in the "Body" tag. The best practice is to place this element . At the end of all these elements "H1" and "p". So why? There are two reasons: the first reason is that the browser scans the file from top to bottom so if you put the script element in the "Head" tag. The browser will be preoccupied with executing and parsing the code when it's supposed to render the content of the page and this will create a bad user experience. The second reason is that the code that we have between the script elements must communicate with the elements of this page, we can for example display or hide some elements. We can be sure that all these elements will be rendered by the browser. Now we'll write the same code we wrote in the previous video so we'll type a console.log "Hello everyone" Here we have a statement, a piece of code instruction that expresses an action to be performed all JavaScript statements must end with a ";" What we call here is a string of characters. This little message will be sent directly to the console. We will write a small message. This comment is only used to only to document the code, it will not be executed by the JavaScript engine. And we have well on the console "Hello everyone". That's it for this video, we'll see you for a next video!