0

Possible Duplicate:
shorthand as // for script and link tags? anyone see / use this before?

I think I understand what is going on but I haven't found anything definitive while googling. In code such as this:

// talking about the src attribute
<script type="text/javascript" src="//use.typekit.net/%kitid%.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>

I am used to http:// being there. When I call this page on an http server it makes a regular HTTP request for the resource so I am assuming this is a shortcut for http://. I am guessing this has to do with not knowing whether the page you are on wants to use https:// or http://? Any articles or anything that have some information on this practice?

Community
  • 1
  • 1
Austin Pray
  • 4,926
  • 2
  • 22
  • 30
  • 2
    That is called a "protocol-relative URL". It will use the protocol that the parent page was requested with. – Michael Berkowski Sep 12 '12 at 16:23
  • Also http://stackoverflow.com/questions/4071117/uri-starting-with-two-slashes-how-do-they-behave http://stackoverflow.com/questions/4978235/absolute-urls-omitting-the-protocol-scheme-in-order-to-preserve-the-one-of-the http://stackoverflow.com/questions/7693598/using-instead-of-protocol http://stackoverflow.com/questions/5799577/does-using-www-example-com-in-javascript-chose-http-https-protocol-automatical http://stackoverflow.com/questions/8254646/absolute-paths-beginning-with-two-slashes – random Sep 12 '12 at 16:24
  • 1
    That's the problem with those questions : you know how to call the object only when you have the answer... – Denys Séguret Sep 12 '12 at 16:26
  • Or just search for "double slash" or "two slashes" if you don't know @dys – random Sep 12 '12 at 16:27

1 Answers1

8

Using //, the request will mimic the protocol from the parent's page.

Have a look at this: http://paulirish.com/2010/the-protocol-relative-url/

472084
  • 17,666
  • 10
  • 63
  • 81