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

In JavaScript and the DOM video - A simple example. Why is not the CSS-folder needed in script-tag of the app.js file?

Why does this work to linke to the app.js <script src = "app.js" ></script>?

Should it not be: <script src = "css/app.js" ></script> ?

1 Answer

Steven Parker
Steven Parker
243,201 Points

The location of files in specific folders is only a convention and not a technical necessity. The important thing is for the path to accurately reflect where the file is located on the system. In this case, the "app.js" file is located in the same folder as the HTML file, so the the folder part of the path is not used.

Also, if a folder were to be used, the common convention is to use a folder name associated with the type of file. So the "css" folder would normally only contain style sheets and not JavaScript code files. A more appropriate location for this file might be "js/app.js".