defer

Script tags using async or defer

0:00
Toggle fullscreen Fullscreen button

Sharing buttons:

okay today I want to talk about the

async and defer attributes that you can

add to script tags so I've got a sample

web page here we've got a header some

main content and then there's a script

tag which I've intentionally stuck in

the middle just to illustrate the point

that I'm trying to make here so we have

the HTML a script some more HTML and

then it gets down to the bottom now

what's gonna happen when you do this

when you put your script anywhere inside

the file the browser reads through this

it parses the HTML till it gets to this

point once it sees oh hey there's a

script tag here it at that point will go

off fetch the script bring it back parse

and execute the script as needed and

then it comes back and starts parsing

the rest of the HTML so when I run this

page this is what we're getting here now