-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(docs): Gatsby script component #35647
Conversation
b118d3c
to
4239079
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a first pass on this
<Script src="https://my-example-script" strategy="off-main-thread" /> | ||
``` | ||
|
||
Additionally, Gatsby exports a `ScriptStrategy` enum that you can use in TSX files if you prefer: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to state the 2 approaches here? I would recommend showing only the ScriptStrategy
as it is less error-prone but I don't have strong feelings about it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JavaScript users will get code completion for string literals so I think it's useful to document both. It was also a point of feedback in the RFC
|
||
#### Forward collection | ||
|
||
Gatsby will collect all `off-main-thread` scripts on a page, and automatically merge any [Partytown forwarded events](https://partytown.builder.io/forwarding-events) defined via the `forward` property into a single configuration for each page: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we be more explicit here and mention that this is only working on Gatsby Cloud?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forward collection happens during SSR in the build process, so this works on any hosting service since it's in the output HTML
Description
Documentation for the Gatsby script component.
Documentation
Pages added:
Pages modified:
Related issues
[sc-48161]