External scripts added with `next/script` load only once
See original GitHub issueWhat version of Next.js are you using?
12.0.2
What version of Node.js are you using?
14.17.6
What browser are you using?
Chrome, Safari, Firefox
What operating system are you using?
macOS
How are you deploying your application?
Vercel
Describe the Bug
While trying to integrate external scripts with next/script
, I noticed that they load only once on a page or component mount. I’ve created a quick demo to describe it more visually.
Expected Behavior
I expect the status to turn green every time I visit the page using website navigation links without reloading.
To Reproduce
Issue Analytics
- State:
- Created 2 years ago
- Reactions:11
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Basic Features: Handling Scripts - Next.js
This script will load and execute when any route in your application is accessed. Next.js will ensure the script will only load once,...
Read more >Next.js inline script only loads once - Stack Overflow
Here are the steps to adding tiny-slider to a next.js app. Add a pages/_document.js to load the styles. // pages/_document.js import { Html, ......
Read more >next/script onLoad run once per cache Key (id, src) #30962
I just need same feature (fire onLoad every time, when script is added to attach some event listener). Any news here? Meanwhile I...
Read more >Optimizing third-party script loading in Next.js
This article discusses the Next.js Script component and demonstrates how it can be used for better sequencing of third-party scripts.
Read more >The Script component in Next.js? - Medium
The nextjs script component onLoad property takes a function as a value. You pass arrow or regular function it bases on the requirement....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you for looking into this!
Yes, making the script load every time should be default as it’s expected with vanilla JS.
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.