1

I am creating a browser based game with phaser, which involves linking to an external javascript file with my own code in it. For some reason when I use either

<script type="text/javascript" src="/js/main.js"></script> or

<script type="text/javascript" src="js/main.js"></script>

to link the javascript to the HTML, no 404 is thrown but the script does not run. However, if I move main.js to the root directory and put

<script type="text/javascript" src="main.js"></script>

in the exact same spot, the script runs fine. Any theories as to why this is? I am using chrome version 57.0.2987.133. Thanks in advance!

1 Answers1

0

It should be:

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

You had a simple scoping error and forgot the script's src.

Jordan Schuetz
  • 1,036
  • 1
  • 10
  • 19