Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

links without http: like //code.jquery.com/etc [closed]

Lately I've noticed that some sites (such as jsFiddle) and some widgets such pinterest feed widget, and many others.

They started to use links in the format

  • //code.jquery.com/jquery-1.9.1.js
  • //assets.pinterest.com/js/pinit.js

    1. what does the // means ?
    2. is it the same as http ?
    3. if // is the same as http why using it instead of http ?
    4. if both are different, can I use it to link my website ?

as addition: I'm not sure, but I think I've seem some use //name:sub.domaine.com, am I wrong ? if those exist, what do they mean ?

Edit:

as explained in an answer bellow, I can use the // notation to make my links shorter, but when I use it for my website: Chrome changes the link to: file:/// which is not what I expected

like image 467
Abu Romaïssae Avatar asked Oct 05 '22 14:10

Abu Romaïssae


1 Answers

This is a protocol-relative URL. If the page which includes it uses HTTP, then it's HTTP. If the page which includes it uses HTTPS, then it uses HTTPS.

This is convenient so that you can ensure that you don't fetch insecure resources in a secure page (this causes the "mixed content" warning you might have seen), without bothering with the overhead of SSL/TLS in a page which is delivered unencrypted anyhow.

It's similar to how URLs beginning with a single / are resolved relative to the current protocol and hostname, and URLs with no leading / or scheme are resolved relative to the current page's directory.

like image 102
Jeremy Roman Avatar answered Oct 13 '22 11:10

Jeremy Roman