protocol relative URL

From IndieWeb

A protocol relative URL (AKA PRURL) is a URL on a page (hyperlink, image source or similar) that starts with "//" and re-uses the protocol of the page itself, typically re-using http: or https: from how the page was loaded, which used to be a common web development practice and is now generally discouraged for various performance and security reasons.

Why not


How to

How to link same site images

For images (and other media files on your site), rather than a protocol relative URL, use a domain relative or current page relative URL.

If the images are literally part of the page and you expect them to move together (e.g. if you change your URL design), then use a current page relative URL.

If the images are in a separate global directory on your site, like /images/example.jpg then use a domain relative URL.

How to link subdomain images

If your images (or other media files) are served from a subdomain, like images. in order to use a different hosting service like AWS for large static files, you should use absolute https:// URLs rather than protocol relative because any modern static file hosting service already supports https, and you especially want HTTPS performance and security advantages for (potentially multiple) large files being retrieved from another site.

See Also