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 Link to an External Script

There are two files: a web page, index.html, and a JavaScript file, shout.js. To run any programming in the shout.js fil

There are two files: a web page, index.html, and a JavaScript file, shout.js. To run any programming in the shout.js file, you first need to load it into the index.html file. Add the required HTML to load the external JavaScript file into the web page. Make sure to add your code inside the <body> of the page.

index.html
<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
</head>
  <body><script> src.shout.js </script>

</body>
</html>
shout.js

16 Answers

Steven Parker
Steven Parker
231,269 Points

The src attribute goes inside the beginning script tag.

Then you need an equal sign between the attribute and the value, and it's good practice to enclose the value in quotes. So for example, to load a file named shout.js, you would add this to the HTML:

<script src="shout.js"></script>
yk2
yk2
8,550 Points

This is how it should be done: <script src = "shout.js"></script>

You need to keep the first script tag open and close it after "shout.js" , also make sure you put quotes between shout.js

I did like this ,but it is does not work for me <script src = "shout.js"></script> do you guys have any idea where I made mistake?

im still confused

here is my code <html> <head> <meta charset="utf-8"> <title>JavaScript Basics</title> <script scr="app.js"></script> </head> <body>

</body> </html>

how can I know what should I put in body , could you please help me ?

Thanks Steven

I am still getting error when write the code in the belwo format

<script> src=shout.js </script>

Can anyone help why i am getting the error like i am missing the end tag like <script>, what is the solution.

src should be enclosed :)

never mind i got it

<script src="shout.js"></script>

yk2
yk2
8,550 Points

How come when I type this, I get an error message?

<body> <script src="shout.js"></script>

</body>

Perfect thanks for the help.

</head> <body> <script src="shout.js"></script> </body> </html>

steven parker please i dont am not getting the code right bummer keeps coming on

Steven Parker
Steven Parker
231,269 Points

You need to show your code to make it possible to identify the issue.

Also, always create a fresh, new question instead of adding one as an "answer" to an old one.

<body> <script src="app.js"></script> <body>

This is correct.

Did you specify the correct file -- app.js -- for the src attribute? thats the error code I keep getting

it should specify to < script src="app.js"></script>