10

I know that HTTP is hyper text transfer protocol, and I know that's how (along with HTTPS) one accesses a website. However, what does just a // do? For instance, to access Google's copy of jQuery, one would use the url //ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js, as opposed to http://....

What exactly is the difference? What does just // indicate?

Thanks.

735Tesla
  • 3,162
  • 4
  • 34
  • 57
mjkaufer
  • 4,047
  • 5
  • 27
  • 55
  • possible duplicate of [Why using href="// instead of href="http:// in HTML?](http://stackoverflow.com/questions/21293029/why-using-href-instead-of-href-http-in-html) – unor Jan 31 '14 at 23:47

2 Answers2

9

By saying on // it means use whatever protocol (IE: http vs https) your user is currently hittin for that resource.

So you don't have to worry about dealing with http: vs https: management yourself.

Avoiding potential browser security warnings. It would be good practice to stick with this approach.

For example: If your user is accessing http://yourdomain/ that script file would automatically be treated as http://ajax.googleapis.com/...

Timeout
  • 7,759
  • 26
  • 38
3

if your current request is http

//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js 

will be treated as

http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js

if your current request is https

//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js 

will be treated as

 https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
hemanth
  • 1,033
  • 8
  • 12