1

I included four .js libraries in my html file as below:

<script type="text/javascript" src="js/three.min.js" /> <script type="text/javascript" src="js/stats.min.js" /> <script type="text/javascript" src="js/TrackballControls.js" /> <script type="text/javascript" src="js/TubeGeometry.js" />

But when I executed it on Safari, it messaged that:

'can't find Variable THREE'

which is in three.min.js.

Then I noticed that actually only stats.min.js has been loaded. Can anybody tell me why please? Many thanks in advance!

Marcos Pérez Gude
  • 21,869
  • 4
  • 38
  • 69
  • 2
    You might give this a look. http://stackoverflow.com/questions/69913/why-dont-self-closing-script-tags-work – ddsnowboard Feb 24 '16 at 17:02
  • 1
    What was the status from the request? Is it a 404 for example meaning the requested file cannot be found? – ste2425 Feb 24 '16 at 17:02
  • You say you noticed that only stats.min.js was loaded - are you sure? Also, try navigating in the browser to http://yourdomain.com/js/three.min.js, http://yourdomain.com/js/TrackballControls.js and http://yourdomain.com/js/TubeGeometry.js - if any of those fail to open, then check your file names/paths. – Matthew Lymer Feb 24 '16 at 17:03
  • Are the correct files located in your `js` folder? And you should probably switch to `` instead of the self closing tag. – Tennyson H Feb 24 '16 at 17:05
  • So all the .js files are in the folder called js, which is in the same place as the html file. They are all openable on Safari without any errors. Just when I included them in html file, three.min.js is still not loaded after using . There's no 404 or something like that, but indicated that a variable which is from three.min.js cannot be found. Anybody knows why? – Abby Wanyu Liu Feb 24 '16 at 17:15

1 Answers1

3

You can't close <script> tags with single tag <script />. For the <script> tag is mandatory the open and close tag:

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

Why? Because your code:

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

Is saying that the first script is empty and it doesn't, it has the remote content.

You can see more :

https://www.w3.org/TR/xhtml1/#C_3

Element Minimization and Empty Element Content

Given an empty instance of an element whose content model is not EMPTY (for example, an empty title or paragraph) do not use the minimized form (e.g. use <p> </p> and not <p />).

Marcos Pérez Gude
  • 21,869
  • 4
  • 38
  • 69
  • Hi thank you very much for your quick response. Just tried to close it by adding but three.min.js is still not included. Don't know why... – Abby Wanyu Liu Feb 24 '16 at 17:09
  • Are you closing all the script tags? If yes, you need to inspect the **Network** tab in the developer tools of your browser (all browsers have one). – Marcos Pérez Gude Feb 24 '16 at 17:10
  • Yes I did and I'm using the web inspector. That's where I know that there's only 4 resources (the html file plus 3 .js files) but three.min.js was missing. Do you know how I can solve this? Really appreciate it. – Abby Wanyu Liu Feb 24 '16 at 17:18
  • But in network tab you can see the load of the resources. You see any 404 or 500 error in the three.min.js? – Marcos Pérez Gude Feb 24 '16 at 17:20
  • There's no 404 or 500 but indicated that a variable which is from three.min.js cannot be found. – Abby Wanyu Liu Feb 24 '16 at 17:21
  • So you need to provide a working example. With the details you attach (your problem is the self-closing script tags) and the explanation you give (*Then I noticed that actually only stats.min.js has been loaded.*) is impossible to see what happens. Read this and then come back and share the correct example: http://stackoverflow.com/help/mcve – Marcos Pérez Gude Feb 24 '16 at 17:23
  • I wrote a small test html that included three.min.js, it worked. But the original html still didn't load it... – Abby Wanyu Liu Feb 24 '16 at 17:24
  • 1
    I can't see more. I haven't got a crystal ball. Understand it, please, we are not magicians. Maybe you can attach a URL with the problem or a screenshot of your webdeveloper tools console network tab – Marcos Pérez Gude Feb 24 '16 at 17:25