Will protocol-relative URLs for HREFs perform as well as a relative path?

199 views Asked by At

Let's say I simply want to link to another page within my site. I can use the following options:

<!-- relative path -->
<a href="/order-pizza.html">Order Pizza</a>

<!-- absolute path -->
<a href="http://www.mywebsite.com/order-pizza.html">Order Pizza</a>

<!-- protocol-relative path -->
<a href="//www.mywebsite.com/order-pizza.html">Order Pizza</a>
  1. Is there a difference in response time when comparing protocol-relative to relative?
  2. Are there any drawbacks when using protocol-relative paths with HREFs?
1

There are 1 answers

2
SLaks On

Relative, absolute, or protocol relative URLs are browser features.
The browser combines the new URL with the page URL to build a complete URL to send a request to.

It has no effect on the network.