0

Is it good to implement website elements like css, javascripts, images or web links without the protocol?

For example: jquery.com offer the cdn-file without:

//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js

Pro for using is, that they automatically use the current protocol (http or https). Even the links are shorter (okay, just 4/5 signs). Are there any cons or should I use it on my own website?

Is there any definition about how browsers deal with this kind of links (official standard)?

Cœur
  • 37,241
  • 25
  • 195
  • 267
bastey
  • 668
  • 2
  • 11
  • 17
  • 2
    already asked here http://stackoverflow.com/questions/11036551/absolute-full-urls-without-http-in-html-href – Tib Sep 03 '13 at 12:50
  • And the second part with any official standard? Or does every browser (even the old) support it? – bastey Sep 03 '13 at 13:07

1 Answers1

1

href without protocol (Protocol-relative URL) is used to remove the naggy warning of accessing unsecure content in IE.

But it'll cause double download in IE7 and IE8 (alas, WHY U NO SMART!!!).

The standard RFC3986 is mentioned in Paul Irish's article. But standard can only serve as a reference in web development, the browser vendors' implementations is more important. Websites like Can I Use, WebPlatform documents this info.

Do refer to these links:

http://www.paulirish.com/2010/the-protocol-relative-url/

http://blog.httpwatch.com/2010/02/10/using-protocol-relative-urls-to-switch-between-http-and-https/

http://www.stevesouders.com/blog/2010/02/10/5a-missing-schema-double-download/

Community
  • 1
  • 1
leesei
  • 6,020
  • 2
  • 29
  • 51