Avoid using the protocol on inline website elements?

59 views Asked by At

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)?

1

There are 1 answers

0
leesei On BEST ANSWER

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/