sainture
6/8/2015 - 3:50 PM

CDN links to Bootstrap/jQuery "//maxcdn" vs "http://maxcdn" vs "https://maxcdn"

CDN links to Bootstrap/jQuery "//maxcdn" vs "http://maxcdn" vs "https://maxcdn"

<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
vs
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">


When loading html from a local file, use 
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">

When your html is delivered by a web server, you can use
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">

When using a CDN, is usually a good idea to not to specify the protocol, so your browser will use http or https depending on the protocol used to get your html in the first place. This is important because if your server is using https, it is better to have all references using https to avoid browsers (specially IExplorer) complaining about mixing content. On the other hand, using a protocol-less URL for CDN is more cache friendly.

Unfortunately, a protocol-less URL is a bad idea if the protocol is file://. So if you are creating a private HTML that will be loaded from disk, then you should add the protocol (http://maxcdn).