I'm a beginner in web dev and I've recently come across some code that includes two external JS files in the following way:
<script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
<script src="//d3js.org/d3.v3.min.js" charset="utf-8"></script>
I know the browser will perform additional HTTP-requests to get the referenced files. Now, this is what's got me wondering:
When I put the containing HTML-file into the XAMPP htdocs folder and access it via localhost, everything works fine. However, when I just open the local .html-file in Chrome oder Firefox, it won't be able to find these external JavaScripts.
Obviously, this isn't a problem, since you wouldn't normally use an HTML-file that way, but I still wonder what happens here. Does it need some kind of server to include external JS files? Interestingly, it works when I include the files like this:
<script src="http://ift.tt/JmLP3T" charset="utf-8"></script>
It would be really interesting to know why =)
Cheers!
Aucun commentaire:
Enregistrer un commentaire