Path to javascript source code at local browsing

Where should I put my javascript source code in order to run it "locally" by file not by http?---not sure this "locally" is the appropriate word here.
My test is when my javascript code (test.js) is put in the site default folder as the test.html in /var/www/html both worked as expected with http:

http://localhost/test.html
<script type="text/javascript" src="/test.js"> </script>

However, when I tried to test it at URL window with file:

file:///home/davids/study/WebTech/test.html

I can see my html result, but my javascript code was not executed.
Where should I put the external javascript source code (here:test.js) in order to test it "locally"?

Thanks!

You need to supply the correct (relative or absolute) path to test.js . As given, the html script will look into the root directory (unless chrooted).

1 Like

Thanks!
Ahh, back slash "/" - that is the root!