Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Michael Welsh
seal-mask
.a{fill-rule:evenodd;}techdegree
Michael Welsh
Front End Web Development Techdegree Student 9,248 Points

Why does Dave's HTML load before the Javascript runs. Mine doesn't, and looking at his code doesn't solve this.

He doesn't seem to be using the window.onload = function() { ALL YOUR SCRIPT HERE } technique or async (which I have never been able to get to work for me).

Thanks in advance for any answers you can provide.

1 Answer

Seth Kroger
Seth Kroger
56,413 Points

Dave (and lots of others) loads his scripts at the bottom of the HTML body, right before the closing body tag, instead of in the head or the middle of the body. At that point, everything else in the HTML/DOM has been loaded so there's no issue with missing items that are still loading.

Michael Welsh
seal-mask
.a{fill-rule:evenodd;}techdegree
Michael Welsh
Front End Web Development Techdegree Student 9,248 Points

I do as well.

I should have just added my code to the question. I am not at home any more and can't add it from my phone. It is basically the same as the workspaces code except the H1 doesn't load when the prompt appears.