From 460e19f0aa3799c8cb2b12485fca387120bb3a45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Orb=C3=A1n?= Date: Tue, 1 Nov 2022 20:38:15 -0700 Subject: [PATCH] docs(script): explain expected `next/script` behavior on client-side navigation (#42260) This PR explains that a navigation via `Link` would not re-execute `next/script` components once they are added. Fixes #42111 Ref: [slack thread](https://vercel.slack.com/archives/C02UJ0QH45Q/p1667237775929339) ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm build && pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md) Co-authored-by: JJ Kasper --- docs/basic-features/script.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/basic-features/script.md b/docs/basic-features/script.md index 4ce8ed96cd13e..74363e76d94cc 100644 --- a/docs/basic-features/script.md +++ b/docs/basic-features/script.md @@ -90,6 +90,8 @@ Although the default behavior of `next/script` allows you load third-party scrip Refer to the [`next/script`](/docs/api-reference/next/script.md#strategy) API reference documentation to learn more about each strategy and their use cases. +> **Note**: Once a `next/script` component has been loaded by the browser, it will stay in the DOM and client-side navigations won't re-execute the script. + ### Offloading Scripts To A Web Worker (experimental) > **Note:** The `worker` strategy is not yet stable and does not yet work with the [`app/`](https://beta.nextjs.org/docs/routing/defining-routes) directory. Use with caution.