Skip to content

Instantly share code, notes, and snippets.

@pj8912
Created November 13, 2024 15:09
Show Gist options
  • Save pj8912/a2075f2650ad89b9ea7051768159e3f2 to your computer and use it in GitHub Desktop.
Save pj8912/a2075f2650ad89b9ea7051768159e3f2 to your computer and use it in GitHub Desktop.
elements that can use referrerPolicy attribute

The referrerPolicy attribute can be used on any element that makes network requests. Here are the main ones:

  1. Link elements:
<a href="..." referrerPolicy="no-referrer">Link</a>
<link rel="stylesheet" href="..." referrerPolicy="no-referrer">
  1. Media elements:
<img src="..." referrerPolicy="no-referrer">
<video src="..." referrerPolicy="no-referrer">
<audio src="..." referrerPolicy="no-referrer">
  1. Embeds/iframes:
<iframe src="..." referrerPolicy="no-referrer">
<embed src="..." referrerPolicy="no-referrer">
<object data="..." referrerPolicy="no-referrer">
  1. Resource fetching:
<script src="..." referrerPolicy="no-referrer">
<source src="..." referrerPolicy="no-referrer">

You can also set a global referrer policy for all requests using a meta tag:

<meta name="referrer" content="no-referrer">

The available policy values are:

  • no-referrer
  • no-referrer-when-downgrade (default)
  • origin
  • origin-when-cross-origin
  • same-origin
  • strict-origin
  • strict-origin-when-cross-origin
  • unsafe-url

Most commonly you'll see this used on images and iframes for privacy/security reasons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment