Unverified Commit 196957fd authored by GJunior's avatar GJunior Committed by GitHub

Next/Script documentation beforeInteractive inconsistency (#44898)

Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
Closes https://github.com/vercel/next.js/issues/43566
parent c35aec8d
......@@ -71,22 +71,27 @@ 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 occuring.
`beforeInteractive` scripts must be placed inside `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).
`beforeInteractive` scripts must be placed inside `pages/_document.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).
**This strategy should only be used for critical scripts that need to be fetched before any part of the page becomes interactive.**
```jsx
import { Html, Head, Main, NextScript } from 'next/document'
import Script from 'next/script'
export default function MyApp({ Component, pageProps }) {
export default function Document() {
return (
<>
<Script
src="https://example.com/script.js"
strategy="beforeInteractive"
/>
<Component {...pageProps} />
</>
<Html>
<Head />
<body>
<Main />
<NextScript />
<Script
src="https://example.com/script.js"
strategy="beforeInteractive"
/>
</body>
</Html>
)
}
```
......
......@@ -307,7 +307,6 @@ async function run(): Promise<void> {
typeof program.importAlias !== 'string' ||
!program.importAlias.length
) {
console.log({ idk: program.importAlias })
if (ciInfo.isCI) {
program.importAlias = '@/*'
} else {
......
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