CodePark/ questions / Third-party scripts
START PRACTICINGPRACTICE
Frontend question · Browser & web performance › Third-party scripts

In Next.js, which next/script strategy suits a feedback widget that nobody needs in the first seconds of a visit?

<Script src="https://widget.example.com/feedback.js" strategy="?" />
lazyOnload

lazyOnload loads the script when the browser is idle, after everything else on the page has loaded. That is right for low-priority widgets.

"
afterInteractive" is the tempting wrong answer. It is the default and loads the script soon after hydration starts. It fits tag managers and analytics, which need to start early, but it still competes with your own code. beforeInteractive is only for scripts that must run before hydration, like bot detection. worker is experimental and runs the script in a web worker through Partytown.