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 trialDaniela Fernandes Smith
Courses Plus Student 10,353 PointsWhen I test this code on Google Chrome, it doesn't load the page before the alerts pop up
When I test this code on Google Chrome, it doesn't load the page before the alerts pop up, even though the JavaScript file is at the end of the body tag. Is this normal behavior? How can I get around it and have the page loaded before the alerts pop up?
Thank you!
1 Answer
Temitope Ogunleye
Full Stack JavaScript Techdegree Student 2,186 PointsTry to put JavaScript <script> tags just before the closing </body> tag like below, The reason is because HTML loads from top to bottom:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Functions</title>
<link href="css/style.css" rel="stylesheet">
</head>
<body>
<main>
<input type="text" id="info" value="My info">
</main>
<script src="js/scope.js"></script>
</body>
</html>