Skip to content

Commit 95b47fe

Browse files
committed
Document referrerPolicy for <script>
1 parent 46a54e0 commit 95b47fe

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

  • src/content/reference/react-dom/components

‎src/content/reference/react-dom/components/script.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Other supported props:
4646
* `integrity`: a string. A cryptographic hash of the script, to [verify its authenticity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity).
4747
* `noModule`: a boolean. Disables the script in browsers that support ES modules — allowing for a fallback script for browsers that do not.
4848
* `nonce`: a string. A cryptographic [nonce to allow the resource](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce) when using a strict Content Security Policy.
49-
* `referrer`: a string. Says [what Referer header to send](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#referrerpolicy) when fetching the script and any resources that the script fetches in turn.
49+
* `referrerPolicy`: a string. Specifies the [referrer policy](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#referrerpolicy) for fetching the script and any modules it imports.
5050
* `type`: a string. Says whether the script is a [classic script, ES module, or import map](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type).
5151

5252
Props that disable React's [special treatment of scripts](#special-rendering-behavior):
@@ -109,6 +109,8 @@ export default function Page() {
109109

110110
<Note>
111111
When you want to use a script, it can be beneficial to call the [preinit](/reference/react-dom/preinit) function. Calling this function may allow the browser to start fetching the script earlier than if you just render a `<script>` component, for example by sending an [HTTP Early Hints response](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/103).
112+
113+
If you need to set a `referrerPolicy`, skip `preinit` for that script. An earlier `preinit` call for the same URL can start fetching the script without the policy set on `<script>`.
112114
</Note>
113115

114116
### Rendering an inline script {/*rendering-an-inline-script*/}

0 commit comments

Comments
 (0)