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

Link tags do not populate Scripts on renavigation #42111

Closed
1 task done
temrb opened this issue Oct 29, 2022 · 2 comments · Fixed by #42260
Closed
1 task done

Link tags do not populate Scripts on renavigation #42111

temrb opened this issue Oct 29, 2022 · 2 comments · Fixed by #42260
Labels
Script (next/script) Related to Next.js Script Optimization.

Comments

@temrb
Copy link

temrb commented Oct 29, 2022

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Refer to #42088

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

Refer to #42088

The script will only be fetched and executed when this specific page is loaded on the browser.

Untitled.mov

If you need to execute some code after the script has loaded, you can check out the onLoad or onReady event callbacaks.

That is the only main script that is supposed to be loaded... Which is not being loaded using link as noted in the recording.

It has been an issue since 2018. Unless I missed something from the docs that say there is another way to handle this..

#42088 has been closed too early.

Currently I am using a tag which refreshes the page, where as link tag doesnt Which is the main reason IMO this doesnt load it.

Expected Behavior

Refer to #42088

Link to reproduction

https://github.com/temrb/next-link-issue

To Reproduce

https://github.com/temrb/next-link-issue

@temrb temrb added the bug Issue was opened via the bug report template. label Oct 29, 2022
@balazsorban44 balazsorban44 added the Script (next/script) Related to Next.js Script Optimization. label Oct 31, 2022
@balazsorban44
Copy link
Member

Could you clarify the use case?

My explanation from earlier #42088 (comment) refers to the docs, but we can clarify it. So when a script has been loaded in the browser, a client-side navigation is not expected to remove/re-add/re-execute that script, hence the current behavior is as expected.

@balazsorban44 balazsorban44 added area: documentation and removed bug Issue was opened via the bug report template. labels Oct 31, 2022
@temrb temrb closed this as completed Nov 1, 2022
ijjk added a commit that referenced this issue Nov 2, 2022
…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 <[email protected]>
@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Script (next/script) Related to Next.js Script Optimization.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants