Open dquilter opened 2 years ago
https://nextjs.org/docs/basic-features/script#executing-code-after-mounting-onready
onReady
prop, this will help ;)
https://nextjs.org/docs/basic-features/script#executing-code-after-mounting-onready
onReady
prop, this will help ;)
I see, this can solve it. The method is called every time the component is mounted. I just don't know what to call there, force the page to refresh? The script is already loaded, but I need to run it again on re-navigation.
I have the same issue as natBizitza and the same questions as hers too. Any suggestions anyone?
I have a reproduction of the issue here using the the pages router: https://github.com/JasonA-work/tidycal-next-js-embed-error
It's hosted on Vercel, so you can verify the error here: https://tidycal-next-js-embed-error.vercel.app/
I've also tried this with the app router, and the iframe from the script doesn't load at all no matter how I try to manage it.
@leerob
We've been stuck with not being able to use third-party widgets and such for a while because of this. We have reproductions available for the team to check out too.
Thank you so much!
Doing a re-write of our application at work and am running into this issue. I've used many suggestions, but nothing works. I hope they will address it soon.
Upping this: we require a third-party script to initialise a widget on a few of our pages, but navigating within the app to those pages does not run the script after the first instance.
We're also experiencing this when loading a script that shows a cookiebanner. Once is fine, but it disappears on navigation. Any solutions to this?
Same issue here trying to use an inline subscription widget. How are we supposed to use onReady? It only refers to external scripts, mine is inline and has no init call.
Having the same issue ...
Same issue here, Using Tidycal cdn script to display calendar (the only way provided to embed calendar from tidycal). the script load and display the content on first page load but after navigating to other pages in the app and coming back, the html content injected by the script is not there anymore.
We are also running into the same issue. Making the script load every time should be default as it's expected with Vanilla JS.
Verify canary release
Provide environment information
What browser are you using? (if relevant)
Chrome 103.0.5060.134 (Official Build) (arm64)
How are you deploying your application? (if relevant)
No response
Describe the Bug
An inline script (using Next Script) will only run the first time the page is visited. If the user navigates internally to other pages and then comes back to the original page (again, via internal navigation), the script will not run a second time.
Tested using the
lazyOnload
,beforeInteractive
andafterInteractive
strategies.Removing the ID attribute from Script results in the script being run on subsequent page loads.
Expected Behavior
Whenever a page is visited, inline scripts will be run, regardless of whether the page has already been visited in that session.
Link to reproduction
https://stackblitz.com/edit/nextjs-vyvasp?file=pages/index.js
To Reproduce
(Scripts are located in
Navigation
component; there are a number from previous testing that have been commented out to reduce console noise.)