Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
947ee9dd
Unverified
Commit
947ee9dd
authored
Jun 16, 2021
by
Tim Neutkens
Committed by
GitHub
Jun 16, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update note in script doc (#26214)
parent
2967fe1d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
12 deletions
+20
-12
script.md
docs/basic-features/script.md
+20
-12
No files found.
docs/basic-features/script.md
View file @
947ee9dd
...
...
@@ -25,16 +25,16 @@ import Script from 'next/script'
Three loading strategies will be initially supported for wrapping third-party scripts:
-
beforeInteractive
-
`beforeInteractive`
-
script is fetched and executed _before_ page is interactive (i.e. before self-bundled javascript is executed)
-
script is injected in SSR’s HTML - similar to self-bundled JS
-
afterInteractive
(
**default**
)
-
`afterInteractive`
(
**default**
)
-
script is fetched and executed _after_ page is interactive (i.e. after self-bundled javascript is executed)
-
script is injected during hydration and will execute soon after hydration
-
lazyOnload
-
script is injected at
onload
, and will execute in a subsequent idle period (using
`requestIdleCallback`
)
-
`lazyOnload`
-
script is injected at
`onload`
, and will execute in a subsequent idle period (using
`requestIdleCallback`
)
NOTE: above strategies work the same for inline scripts wrapped with ScriptLoader
.
> Note: above strategies work the same for inline scripts wrapped with `<Script>`
.
## Example scenarios
...
...
@@ -82,10 +82,18 @@ import Script from 'next/script'
## Which third-party scripts to wrap with Script Loader
We recommend the following Script Loader strategies for these categories of third-party scripts
| Loading strategy | third-party categories |
| ----------------- | -------------------------------------------------------------------------------------------- |
| beforeInteractive | polyfill.io
<br>
Bot detection, security & authentication
<br>
User consent management (GDPR) |
| afterInteractive | Tag-managers
<br>
Analytics |
| lazyOnload | Customer relationship management eg. Google feedback, chat support widget
<br>
Social networks |
We recommend the following Script Loader strategies for these categories of third-party scripts:
-
`beforeInteractive`
-
[
polyfill.io
](
https://polyfill.io
)
-
Bot detection
-
Security and Authentication
-
User consent management (GDPR)
-
`afterInteractive`
-
Tag-managers
-
Analytics
-
`lazyOnload`
-
Customer relationship management
-
Google feedback
-
Chat support widget
-
Social networks
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment