So simple, but it's not working

So this is so simple and it was working before. I’m trying to load a JS file into my html. I think I have the file extension correct, but it’s not loading the JS on my page. This is for a JS video I’m following on YouTube.

42 PM

the file:// only works for local file systems, i.e. on your own computer.

If this is hosted on the Internet (codepen, your own website, etc), either use relative paths src="/directory/file.js"
or the complete url src=“

Should it be 3 forward slashes or 2 forward slashes or 1 forward slash at the beginning?

Thanks. This isn’t hosted on any other website. Just my local computer.

I tried it with 2 and 1 slashes and it still didn’t work.

Where is this file in relation to the html file? Is it in the same directory? What is the actual file path for both files (.html and .js)? Is this on Windows or Mac?

Use a relative path instead of an absolute path

This file is in the same folder as the HTML file. This is on a Mac.

The file path is /Users/darrinmaier/Desktop/javascriptBasics/index.html



If they are in the same folder, then the following should work. Let us know.



  <h1>Title goes here</h1>
    paragraph here!

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


Actually, after reviewing your original screenshot, if you both of the files are located in a folder with the following path:


then your script src attribute was wrong, because you referenced a folder called “Javascript_Basics”, which is not the same as “javascriptBasics”.

Hey Thanks for the response. It did not work.

If it helps, I’m using Atom as an editor. In my version of Atom, if I type in a link or file path it turns blue. It won’t turn blue unless I start local paths with “file:///”.

Even correcting the underscore and the uppercase J didn’t work.

I got it. It wasn’t saving the index properly. Thanks so much all!

I use Atom also, but this has nothing to do with Atom. It has to do with proper syntax. If you open this file outside of Atom in a web browser, it will work. What code is in js.js? If you put

alert("The JS file is working...");

inside the js.js file, and open the html file (my code above), it will display an alert.