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

Javasript

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. JS is on my tab, but I just can't do this, I had window 10 prob? Please help

1 Answer

Dave StSomeWhere
Dave StSomeWhere
19,870 Points

An external javascript file can be loaded into an html page using a script element with a src attribute pointing to your javascript file. It is common practice to place this just before the closing </body> tag to allow the page to load the rest of the page first prior to loading your javascript file.

So, if your javascript file is in the same folder as your index.html you can use the following (other wise you'll need to add the path to the file):

<body>

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

Thank you so much Dave! So nice of you Many thanks, Kindest regards Ben