【问题标题】:Avoid using the protocol on inline website elements?避免在内联网站元素上使用协议?
【发布时间】:2013-09-06 17:10:02
【问题描述】:

在没有协议的情况下实现css、javascript、图片或网页链接等网站元素好不好?

例如:jquery.com 提供的 cdn 文件没有:

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

使用的优点是,它们会自动使用当前协议(http 或 https)。甚至链接也更短(好吧,只有 4/5 个标志)。有什么缺点还是我应该在自己的网站上使用它?

有没有关于浏览器如何处理这种链接的定义(官方标准)?

【问题讨论】:

标签: html browser protocols browser-support


【解决方案1】:

href without protocol (Protocol-relative URL) 用于消除在 IE 中访问不安全内容的烦人警告。

但它会导致在 IE7 和 IE8 中重复下载(唉,为什么你不聪明!!!)。

Paul Irish 的文章中提到了标准RFC3986。但标准只能作为Web开发的参考,浏览器厂商的实现更为重要。 Can I UseWebPlatform 等网站记录了这些信息。

请参考以下链接:

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/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-06
    • 2017-11-25
    • 2015-02-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多