1

Today I came across this:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>

Which I think should be this:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>

Can someone explain why all the CDN folks omit the http: in their include snippets? CloudFlare does it too:

//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.2/jquery.min.js

But why? Does even the dumbest browser get this or is it safer to just add http:?

openfrog
  • 40,201
  • 65
  • 225
  • 373
  • 2
    http://stackoverflow.com/questions/4831741/can-i-change-all-my-http-links-to-just – Ian Jun 17 '13 at 13:29

1 Answers1

3

Look http://www.ietf.org/rfc/rfc3986.txt for "relative reference". The path referenced is relative to used scheme. So, if your website is http://www.example.com the http-part is the scheme. Now in "//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.js" the // part signals, that you want to go relative to the scheme of your site, meaning in this case relative to http.

Thomas Junk
  • 5,588
  • 2
  • 30
  • 43