Next.js Discord

Discord Forum

Image Component API... slow load times?

Unanswered
Mandarin fish posted this in #help-forum
Open in Discord
Mandarin fishOP
Hello, I'm using the Image Component API within a dynamic route (i.e. folder [menuItem]).

I'm using the generateStaticParams so I can have those images on those dynamic routes optimized on build time so they're ready to view when a user visits those pages.

Some of the images are taking 10+ seconds to load! Some other information you should know is the original images that the Image API is optimizing are 2mb-5mb. I didn't pre-optimize them because I assumed that's what NextJS's api was doing (correct me if I'm wrong).

If you made it this far, thank you for taking the time to help me with the problem I'm having.

3 Replies

1. Next.js doesn't optimize images on build time. It isn't smart enough to determine which image is referenced in your code and optimize them automatically.
2. Normally it shouldn't take more than 1 second since it's a static asset rather than dynamically generated images, how do you deploy your Next.js app? Surely there's something that makes responding slower than expected.
Mandarin fishOP
I have it deployed to Vercel
Can you provide a reproducible repo (or GitHub repo)?