I often see links like this

//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js

or on http://cdnjs.com/

with no protocol. Why is that? I'm assuming ftp or other protocols wouldn't really be used to link to these.

有帮助吗?

解决方案

That means that the link will use the same protocol that the page where the link is placed is using.

If the link is in a "http://" page, it will use "http://" to open the link. If otherwise it is in a "https://" page, it will use "https://" to open the link.

Why? Because if you are in HTTPS and the page tries to load a image through a non secure URL, some browsers will complain about it. If you are in a non secure page and try to load a secure content that does not need to be secure ... you are creating unnecessary overhead.

It is not exclusive for CDN, you can use it with any link, and it is quite useful.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top