Thursday, January 21, 2016

Using Protocol vs "Protocol-Less" URL (for linking in HTML)

Dev Fam,

Recently I came across some code that upgraded the way I <link> in my web apps (i.e. HTML pages).

New Code (no https/http): 
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" />

Old Code (or traditional way):
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" />

Going "Protocol-Less"

Here is a good discussion on why I've decided to use "protocol-less" URLs in my webapps:
http://stackoverflow.com/questions/4831741/can-i-change-all-my-http-links-to-just

Some more discussion on SO:
http://stackoverflow.com/questions/8997790/why-does-an-anchor-tags-href-values-need-http-preprended-to-the-url

Also notice (tip on referring to local file):
http://stackoverflow.com/questions/12837024/href-file-doesnt-work

Going deep into discussion:
https://moz.com/learn/seo/internal-link

But, it's always up to you as the developer to decide. May the force be with you!

G2

No comments:

Post a Comment