phantom007 — 2013-08-01T07:54:59-04:00 — #1
I have seen people using // instead of http:// when including js/css in their page...anyone know why?
fretburner — 2013-08-01T08:05:20-04:00 — #2
If your page is requested over https, you'll get a warning about including non-secure content if you link scripts over http. By starting your links with //, the browser will use the same protocol that the page is served by.
jeff_mott — 2013-08-01T08:07:02-04:00 — #3
It's a scheme relative URL. So if your page is https, then the js/css request will also be https. Works everywhere, I believe, except that I've read IE8 will issue the request twice, which would be detrimental to performance since the number of HTTP requests is one of the most significant factors. But if IE8 isn't a concern, then there's no reason you can't use scheme relative URLs everywhere.
EDIT: People keep beating me to the punch lately.
phantom007 — 2013-08-01T08:09:36-04:00 — #4
so will it even work if the page requesting is https and googleapis.com does not support https?
fretburner — 2013-08-01T08:11:59-04:00 — #5
No, the server hosting the scripts must be able to serve them via https for that to work.
Edit: @Jeff Mott - I hadn't heard that about IE8 before, that's useful to know.
phantom007 — 2013-08-01T08:18:52-04:00 — #6
oh ok thanks everyone for the responses...
phantom007 — 2013-08-01T08:20:13-04:00 — #7
Does IE make double request, one for http and the other for https?? is it?
fretburner — 2013-08-01T08:42:01-04:00 — #8
Just to clarify on the IE issue, according to this blog post by Paul Irish:
When used on a <link> or @import for a stylesheet, IE7 and IE8 download the file twice. All other uses, however, are just fine.
system — 2014-10-08T00:38:56-04:00 — #9
This topic is now closed. New replies are no longer allowed.