Unverified Commit 8f6f1379 authored by Sam Ko's avatar Sam Ko Committed by GitHub

docs: add Page Router only section for beforeInteractive (#61839)

## Changes

Updates `beforeInteractive` section in API Reference docs for Pages
Router

-
https://nextjs.org/docs/pages/api-reference/components/script#beforeinteractive
- Closes https://github.com/vercel/next.js/issues/61594
parent 3e3c0127
...@@ -70,7 +70,17 @@ Scripts that load with the `beforeInteractive` strategy are injected into the in ...@@ -70,7 +70,17 @@ Scripts that load with the `beforeInteractive` strategy are injected into the in
Scripts denoted with this strategy are preloaded and fetched before any first-party code, but their execution does not block page hydration from occurring. Scripts denoted with this strategy are preloaded and fetched before any first-party code, but their execution does not block page hydration from occurring.
`beforeInteractive` scripts must be placed inside the root layout (`app/layout.tsx)` and are designed to load scripts that are needed by the entire site (i.e. the script will load when any page in the application has been loaded server-side). <AppOnly>
`beforeInteractive` scripts must be placed inside the root layout (`app/layout.tsx`) and are designed to load scripts that are needed by the entire site (i.e. the script will load when any page in the application has been loaded server-side).
</AppOnly>
<PagesOnly>
`beforeInteractive` scripts must be placed inside the `App` Component (`pages/_app.js`) and are designed to load scripts that are needed by the entire site (i.e. the script will load when any page in the application has been loaded server-side).
</PagesOnly>
**This strategy should only be used for critical scripts that need to be fetched before any part of the page becomes interactive.** **This strategy should only be used for critical scripts that need to be fetched before any part of the page becomes interactive.**
...@@ -116,7 +126,7 @@ export default function RootLayout({ children }) { ...@@ -116,7 +126,7 @@ export default function RootLayout({ children }) {
<PagesOnly> <PagesOnly>
```jsx ```jsx filename="pages/_app.js"
import { Html, Head, Main, NextScript } from 'next/document' import { Html, Head, Main, NextScript } from 'next/document'
import Script from 'next/script' import Script from 'next/script'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment