Skip to content
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

Merged
merged 9 commits into from
May 24, 2022
Merged

chore(docs): Gatsby script component #35647

merged 9 commits into from
May 24, 2022

Conversation

tyhopp
Copy link
Contributor

@tyhopp tyhopp commented May 13, 2022

Description

Documentation for the Gatsby script component.

Documentation

Pages added:

Pages modified:

  • Improving site performance how to guide, section on loading third party scripts - Rendered file

Related issues

[sc-48161]

@tyhopp tyhopp added the type: documentation An issue or pull request for improving or updating Gatsby's documentation label May 13, 2022
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label May 13, 2022
@tyhopp tyhopp marked this pull request as draft May 13, 2022 04:08
@tyhopp tyhopp added status: blocked This issue/PR can't be solved at the moment and shouldn't be closed/merged and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels May 13, 2022
@tyhopp tyhopp added this to the Script Component milestone May 13, 2022
@tyhopp tyhopp force-pushed the docs-script-component branch from b118d3c to 4239079 Compare May 23, 2022 09:31
@tyhopp tyhopp marked this pull request as ready for review May 23, 2022 09:38
Copy link
Contributor

@Khaledgarbaya Khaledgarbaya left a 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:
Copy link
Contributor

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

Copy link
Contributor Author

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:
Copy link
Contributor

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?

Copy link
Contributor Author

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

@tyhopp tyhopp requested review from Khaledgarbaya and pieh May 24, 2022 02:25
@pieh pieh dismissed Khaledgarbaya’s stale review May 24, 2022 22:19

Changes were made

@pieh pieh removed the status: blocked This issue/PR can't be solved at the moment and shouldn't be closed/merged label May 24, 2022
@pieh pieh merged commit 21dcb6d into master May 24, 2022
@pieh pieh deleted the docs-script-component branch May 24, 2022 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation An issue or pull request for improving or updating Gatsby's documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants