2

I have noticed that a lot of places that offer shared libraries are not including the http:// in front of the link. Example, cdnjs and google libraries.

//cdnjs.cloudflare.com/ajax/libs/1140/2.0/1140.css

My questions are:

Why? And what's the difference between this?

//cdnjs.cloudflare.com/ajax/libs/1140/2.0/1140.css

and this?

http://cdnjs.cloudflare.com/ajax/libs/1140/2.0/1140.css

2 Answers2

1

Leaving of the http: means that the include will use the same protocol as the page that includes the file - so if you are running your site on https and you embed your external resources using http:// you will see a lot of "unsafe resources" or "blocked resources" If you embed them using // instead they will be fetched using https on an https site - which means they won't be blocked and not considered unsafe.

Take a look here: Two forward slashes in a url/src/href attribute which explains this in great detail

Community
  • 1
  • 1
Birgit Martinelle
  • 1,869
  • 1
  • 12
  • 9
  • Thank you! Although the other answer is also correct. You answered it first. –  Sep 15 '14 at 17:04
1

It'll use http or https for the link to the library depending on the context of the referencing page.

Kern
  • 103
  • 1
  • 5