text
stringlengths
1
81
start
float64
0
10.1k
duration
float64
0
24.9
call an anonymous function a function
2,104.08
4.71
that has no name but I'm still passing
2,106.21
4.32
it into the add event listener function
2,108.79
4.47
as an argument because I want to run the
2,110.53
4.89
code inside of the function once the Dom
2,113.26
4.38
is done loading and so inside of curly
2,115.42
4.17
braces then is the content of that
2,117.64
3.81
function the content of what code should
2,119.59
3.75
run when the Dom is done loading and
2,121.45
3.81
then at the end I again used just this
2,123.34
3.84
end parenthesis where that end
2,125.26
3.54
parenthesis lines up with this
2,127.18
4.17
parenthesis here this is enclosing all
2,128.8
5.07
of the arguments to add event listener
2,131.35
3.96
where the first one is Dom content
2,133.87
3.9
loaded and the second one is this entire
2,135.31
4.86
function that might span multiple lines
2,137.77
4.35
so you'll see syntax like this quite a
2,140.17
5.1
bit in JavaScript but now what I want to
2,142.12
5.28
do is adding the event listener to the
2,145.27
4.32
button I can go ahead and just for place
2,147.4
4.77
and put it here and it turns out that if
2,149.59
3.15
I wanted to
2,152.17
2.37
instead of saying dot on click equals
2,152.74
2.97
count you could
2,154.54
2.579
used the same syntax of add
2,155.71
2.67
eventlistener I could say at
2,157.119
5.071
eventlistener click and then count to
2,158.38
6.57
mean when the click event happens go
2,162.19
4.5
ahead and run the count function but you
2,164.95
3.45
can equivalently shorthand this and just
2,166.69
4.35
say dot on click equals count and that
2,168.4
5.25
would work just as well so now what
2,171.04
4.799
we're saying here is that wait until the
2,173.65
3.75
Dom has done loaded wait until all the
2,175.839
3.811
content on the page is loaded and then
2,177.4
4.29
go ahead and run this function and what
2,179.65
3.719
the function is going to do is it's
2,181.69
3.75
going to add the event handler to this
2,183.369
4.171
button and that'll work because now
2,185.44
3.929
we'll be able to find the button because
2,187.54
3.87
now all of the content of the Dom has
2,189.369
5.191
loaded so now if I go back Refresh
2,191.41
5.25
counter dot HTML you'll notice that the
2,194.56
4.049
JavaScript error goes away I don't seem
2,196.66
4.53
to have that error anymore and now if I
2,198.609
4.411
press count were able to see the count
2,201.19
5.55
increment just as before as well and so
2,203.02
5.849
this then is an improvement upon what
2,206.74
4.16
I've had before where now I'm able to
2,208.869
5.041
separate out my JavaScript code from all
2,210.9
5.469
of the rest of my code as well but much
2,213.91
4.74
as in the case of CSS where we were able
2,216.369
4.021
to take CSS that was originally located
2,218.65
3.78
in the head of our page and move it into
2,220.39
3.719
a separate file you can do the same
2,222.43
3.3
thing with JavaScript too and this can
2,224.109
3.031
be helpful if you have multiple people
2,225.73
3.03
working on different files you want one
2,227.14
3.66
person working on the HTML and someone
2,228.76
4.109
else working on the JavaScript it can be
2,230.8
4.2
helpful if you expect that one of these
2,232.869
3.331
things is going to change more
2,235
2.52
frequently than the other so you might
2,236.2
3
not need to load the other one as often
2,237.52
3.96
so there can be value in separating our
2,239.2
4.59
HTML code from our JavaScript even more
2,241.48
4.35
and by moving our JavaScript into a
2,243.79
4.23
separate file and so in order to do that
2,245.83
5.279
I can create a new file that I'll just
2,248.02
5.91
call counter j/s which will contain all
2,251.109
6.061
of the JavaScript for my counter HTML
2,253.93
6.03
file so in order to do that what I can
2,257.17
5.22
say is let's go ahead and copy all of
2,259.96
4.83
this JavaScript code go ahead and cut it
2,262.39
4.469
out of this page and I'll paste it into
2,264.79
3.9
counter j/s remove some of that
2,266.859
6.151
indentation so now I have a file called
2,268.69
6.63
counter das that just contains all of
2,273.01
4.68
the JavaScript I want to run on my
2,275.32
6.42
counter dot HTML page and now rather
2,277.69
5.82
than include actual JavaScript in
2,281.74
4.65
between these script tags what I can say
2,283.51
6.599
is script SRC SRC first
2,286.39
8.31
equals a counter Jas for example if I go
2,290.109
7.47
ahead and reference counter Jas and use
2,294.7
5.49
that JavaScript in the head of the page
2,297.579
4.47
here and that then is going to work
2,300.19
3.72
exactly in the same way I still am able
2,302.049
3.78
to count as high as I'd like I still get
2,303.91
3.24
an alert every time the count reaches a
2,305.829
3.601
multiple of ten but my HTML is now a
2,307.15
3.929
little bit simpler it's just the body
2,309.43
3.75
it's just the h1 in the button and then
2,311.079
5.191
all of my javascript is now located in a
2,313.18
5.82
separate file that allows me to do that
2,316.27
5.01
allows me to keep my HTML code and my
2,319
3.599
JavaScript code separate from each other
2,321.28
3.24
and that can be value for valuable for a
2,322.599
4.081
couple of reasons among them if I have
2,324.52
4.68