Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference Between // and http://

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.

like image 678
mjkaufer Avatar asked Jan 25 '14 20:01

mjkaufer


2 Answers

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/...

like image 92
Timeout Avatar answered Oct 02 '22 23:10

Timeout


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
like image 22
hemanth Avatar answered Oct 02 '22 21:10

hemanth