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 JavaScript Basics (Retired) Introducing JavaScript Where Does JavaScript Go?

Kent Hefley
Kent Hefley
11,217 Points

Web page loading last.

I have tried clearing my cache and restarting my system. I am using Chrome. I am still getting the the dialogue boxes first and the web page loading last.

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <link rel="stylesheet" href="css/main.css"> <title>JavaScript Basics</title> <script> alert("Here's another message from Treehouse"); </script> </head> <body> <div class="container"> <h1>Where to place your JavaScript code.</h1> </div> <script src="scripts.js"></script> </body> </html>

2 Answers

Allison Hanna
Allison Hanna
36,222 Points

Your alert script (what's loading the dialogue boxes) is loading before the body because of its placement in the <head> tag. If you don't want it to load there, you can move that tag down just before the body close tag </body>.

Kent Hefley
Kent Hefley
11,217 Points

Allison, thank you for your response. My issue is that <script src="scripts.js"></script> (located right before closing body tag) is loading before the page with the <h1>

In the video, this placement has the alert loading first, then the page, then finally the linked script file. What am I missing?

niksalleh
niksalleh
2,827 Points

Same problem as Kent, both dialogues appear first. The web content "Where to place your JavaScript code." only appears after clicking OK to both dialogues. <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <link rel="stylesheet" href="css/main.css"> <title>JavaScript Basics</title> <script> alert("Here's another message from Treehouse"); </script> </head> <body> <div class="container"> <h1>Where to place your JavaScript code.</h1> </div> <script src="scripts.js"></script> </body> </html>