Next.js · Junior · Question 40 of 75
Why load third-party scripts via next/script?
- ✓Correct answer: You can choose a loading strategy (
afterInteractive,lazyOnload, etc.) - 2Only then will scripts work in the production build
- 3
next/scriptautomatically rewrites the script in TypeScript
Explanation
The <Script> component lets you avoid blocking page load with analytics and widgets: beforeInteractive for critical scripts, afterInteractive (the default) and lazyOnload for secondary ones. A script loads once even when navigating between pages.