Asset and script loading
What you need to know
Choose when images, fonts and scripts load according to their importance to the current view. An asset that is unnecessary for first paint should not compete with critical content.
By the end, you can: choose font, image and script strategy; preserve privacy.
Reserve space for a responsive cover
import Image from 'next/image';export default function Cover(){return <Image src='/cover.png' alt='Illustrated river guide cover' width={480} height={320} loading='eager' sizes='(max-width: 600px) 90vw, 320px' style={{width:'100%',maxWidth:320,height:'auto'}}/>;}Expected behavior: The fixture contains an original cover.png. The declared dimensions describe its aspect ratio; CSS constrains display width. Eager loading is a candidate for this above-fold cover; compare with the baseline.
How it works
A responsive image needs appropriate intrinsic dimensions or a reserved aspect ratio and a sizes hint that reflects the CSS slot. A likely LCP image should not be deferred as an ordinary below-fold image. Next.js 16 documents preload for selected critical images and deprecates the older priority prop; do not mark all images for preload. The Image API suggests eager loading or high fetch priority rather than preload for most situations. Use local or system fonts when an offline build is needed; next/font/google may require build-time network access. The Script component supports beforeInteractive for essential early scripts, afterInteractive for scripts needed after hydration starts, and lazyOnload for low-priority scripts. Place beforeInteractive scripts in the App Router root layout and reserve them for truly critical site-wide scripts. The documented worker strategy is experimental and unsupported in App Router; do not use it as an App Router optimization. Every script can execute code with page privileges; inventory its purpose, origin, integrity/update controls, privacy and CSP compatibility. Deferral does not make an untrusted script safe.
Load a harmless local enhancement
import Script from 'next/script';export default function Page(){return <main><h1>Catalog</h1><Script src='/enhancement.js' strategy='lazyOnload'/></main>;}Expected behavior: The included local script only sets a performance mark. It makes no external network requests.
Common mistake
Do not preload every image or assume lazyOnload prevents tracking. A remote font or script can add build dependencies, privacy exposure and runtime failure paths.
Practice and verification
Use a network waterfall to inspect the first cover and the optional script in the staged app. Verify actual image size and alt text. Document the script inventory and remove unnecessary scripts.
Scope: Proposed Next.js 16.x / React 19, App Router with Cache Components disabled unless noted. Framework and browser examples are staged, not executed. Synthetic numbers are not measured performance or actual provider rates.
Further reading: Script · Image · Production