-
Notifications
You must be signed in to change notification settings - Fork 26.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds inline script functionality to
next/script
for worker
and `b…
…eforeInteractive` strategies (#36364) Adds inline script functionality to `next/script` for `worker` and `beforeInteractive` strategies. - fixes #36318 - fixes #26343 - fixes #26591 - fixes #26343 - fixes #26240 Co-authored-by: Janicklas Ralph <6142074+janicklas-ralph@users.noreply.github.com>
- Loading branch information
1 parent
e30d723
commit fd2ba11
Showing
8 changed files
with
248 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Invalid Script | ||
|
||
#### Why This Error Occurred | ||
|
||
Somewhere in your application, you are using the `next/script` component without including an inline script or `src` attribute. | ||
|
||
#### Possible Ways to Fix It | ||
|
||
Look for any usage of the `next/script` component and make sure that `src` is provided or an inline script is used. | ||
|
||
**Compatible `src` attribute** | ||
|
||
```jsx | ||
<Script src="https://example.com/analytics.js" /> | ||
``` | ||
|
||
**Compatible inline script with curly braces** | ||
|
||
```jsx | ||
<Script id="show-banner"> | ||
{`document.getElementById('banner').classList.remove('hidden')`} | ||
</Script> | ||
``` | ||
|
||
**Compatible inline script with `dangerouslySetInnerHtml`** | ||
|
||
```jsx | ||
<Script | ||
id="show-banner" | ||
dangerouslySetInnerHTML={{ | ||
__html: `document.getElementById('banner').classList.remove('hidden')`, | ||
}} | ||
/> | ||
``` | ||
|
||
### Useful Links | ||
|
||
- [Script Component in Documentation](https://nextjs.org/docs/basic-features/script) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters