I've been having trouble with the same issue, mostly in Slider components. Basically, because the image is off-screen until the Slider moves it into view, there is a delay and it doesn't show for a short time, which looks nasty.
Solution:
Add the sharp
package.
The problem comes from the default image processor that NextJS uses. I don't know if this is good for OP, but in my case, I hadn't fully read the docs. There is a tip that states:
The next/image component's default loader uses the 'squoosh' library for image resizing and optimization. This library is quick to install and suitable for a dev server environment. For a production environment, it is strongly recommended that you install the optional sharp library by running
yarn add sharp
in your project directory. If sharp is already installed but can't be resolved you can manually pass the path to it via the NEXT_SHARP_PATH environment variable e.g. NEXT_SHARP_PATH=/tmp/node_modules/sharp
After adding sharp
, my images were processed much faster and there is no noticeable delay anymore. I would try adding this before adding priority={true}
to every image, as that will impact the site performance.
sharp
to your application bundle or, ranyarn add sharp
as a part of the deploy command? – Merozoite