Replies: 39 comments 66 replies
-
@Aviisek Sounds like a server problem. What server and version are you using? How long waiting time do you have on other images? If you look at the response header, does it has a cache policy set? Working on converting our framework to using next/image, and has been very fast this far at least. |
Beta Was this translation helpful? Give feedback.
-
Any updates on this? ... there are more new versions, but still same issue with images ... :( |
Beta Was this translation helpful? Give feedback.
-
I believe a workaround could be if you could modify the "cache-control" header. In such case I could have my Cloudflare Worker proxy cache the image, since I don't expect them to change ever really. |
Beta Was this translation helpful? Give feedback.
-
I have been experiencing this. I just waited 20 seconds while demoing to a client for the images to appear. I was very embarrased |
Beta Was this translation helpful? Give feedback.
-
@Sandstedt thank you. I'm on next 11 and I have the sharp package installed in How would it not be installed on the server? That sounds like something that might be happening. I'll update my config to use the |
Beta Was this translation helpful? Give feedback.
-
@Sandstedt I tried the above suggestions but they did not improve anything that much. I just removed all
I love how easy vercel is to deploy via git push. I love the temporary preview URLs although I do find this unreliable but for images and static asset serving, I found it pretty awful and no real way to make things better outside of next.config. |
Beta Was this translation helpful? Give feedback.
-
the I ended up putting my images in AWS cloudfront |
Beta Was this translation helpful? Give feedback.
-
I experience the same issue on my app deployed on AWS, amplify although I'm setting up sharp as an image loader with environmental variables set up as cited in the issue here. Has anyone encounterd the same issue and found a sloution ? |
Beta Was this translation helpful? Give feedback.
-
Same problem |
Beta Was this translation helpful? Give feedback.
-
Pls is there any solution yet? am also facing this problem |
Beta Was this translation helpful? Give feedback.
-
To fix this problem, first put the most important images to this prop will delete the lazy load from your image and it will be much faster! Also installing sharp can improve this action yarn add sharp npm install sharp |
Beta Was this translation helpful? Give feedback.
-
same. here next js version: 12.3.1 |
Beta Was this translation helpful? Give feedback.
-
I am facing this issue since next 10 I think, no one seemed to care then, and no one seems to care now. Sad |
Beta Was this translation helpful? Give feedback.
-
next image -> img is working to me! |
Beta Was this translation helpful? Give feedback.
-
I have stopped to use |
Beta Was this translation helpful? Give feedback.
-
I think vercel are in denial on thus one. I've had sharp installed forever but I get the same lazy answer that it works on my machine. The whole thing is opaque with no feedback if I'm getting oprimization or not apart from how God damn slow the images are to load. To charge for this is a joke and I'm going to move to remix and be done with next which is very slow on lots of counts |
Beta Was this translation helpful? Give feedback.
-
There are almost certainly multiple causes in this thread but this bug disappeared when I stopped creating my own |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I use the recent nextjs 13, deploy on Vercel. My images are around 200kb, I have Embla carousel with the images. Sometimes the images take a couple of seconds to load... Does anyone have a working solution? I installed sharp, it didn't change anything. |
Beta Was this translation helpful? Give feedback.
-
Hacky, but you could pretty easily build your own image component and then try to load all of your images via something like S3. You can basically just go around the whole optimization if you want. |
Beta Was this translation helpful? Give feedback.
-
Facing the same issue, I've removed the avif from formats in next.config.js and it does load faster, but still a bit slow.
|
Beta Was this translation helpful? Give feedback.
-
I've done numerous a/b comparisons and still not understanding where vercel gets this notion that next/image makes images load "faster". Thats just not true. I suppose if I uploaded a photo directly from my camera, full size, it might be faster as it scales and optimizes that image. I've found just doing some pre-processing and/or using a CDN, (cloudfront, cloudflare, etc) is soooooooo much faster its not even remotely close. I'm using Bunny CDN and optimizing by passing a query string to set the size, crop etc, but any of these inline CDN processors will work. It's obscene the difference in speed. Another thing to consider is next/image requires a serverless function to run. Even if you create a separate loader. I found this out when they sent me a message saying that images will no longer load cause I blew past the 1000 invocation limit in the free vercel hosting. I re-wrote my loader into my own wrapper function and voila - no more limits. Also, you want to be mindful on where you use next/image. Because of these constraints like the function invocation, and requiring window before rendering the image, your design layout will shift as the images become available to load. So for something critical like your logo in the upper left corner you will want to just use the plain old |
Beta Was this translation helpful? Give feedback.
-
Please remember to check Cloudflare DNS settings!I use Cloudflare as my DNS manager but never disabled the proxy on the DNS records for Vercel. For some reason, this caused images to load insanely slow (I'm talking upwards of 10s on some images that were already pre-optimized with quality set to 60%). However, when the proxy is disabled on the DNS records for Vercel, the images load nearly instantly, even after a full reload and on new devices. I hope this helps someone out there. |
Beta Was this translation helpful? Give feedback.
-
Still very slow in 14.2.3. I tried both |
Beta Was this translation helpful? Give feedback.
-
same issue when images are store in AWS S3 (same region with backend), |
Beta Was this translation helpful? Give feedback.
-
Absolutely! The magic is in the aspect ratio of the Image. When you have an
Image with a size of 200x300 and you don't set the aspect ratio to 2-3 in
className or set width and height to 200 and 300 it will be slow. Really
just resizing Images changes everything. If you wanna display the image in
the size 150x250 and set the width and height to 150 and 250 but the image
itself has another aspect ratio, you will have problems. Just resize the
image to a ratio that fits 150-250.
Let me know if this changed your life.
Am Mi., 13. Nov. 2024 um 13:36 Uhr schrieb Ariunaa Myagmar <
***@***.***>:
… Were you able to figure this out?
—
Reply to this email directly, view it on GitHub
<#21294 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BC7XITKSZWIYREYSEJHC7TD2AMMSXAVCNFSM4WHTLOHKU5DIOJSWCZC7NNSXTOSENFZWG5LTONUW63SDN5WW2ZLOOQ5TCMJSGM3TONJR>
.
You are receiving this because you commented.Message ID: <vercel/next.
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Azure CDN was also a gamechanger for me. Can you check the image loading
time. It’s important to know how long it gets requested from the db and how
long it takes to be rendered afterwards.
On Thu 14. Nov 2024 at 09:10, Ariunaa Myagmar ***@***.***>
wrote:
… Hey, thanks! Adding the exact sizing to the class name definitely helped a
bit. I understand what you mean about using the actual aspect ratio of
images. My challenge is that the images in the database are managed by
someone else, and they upload various images with different ratios. We
currently have around 2,000 images in the database, so I’m considering
running a script in the background to resize them to a uniform aspect
ratio.
Let me know if you have other ideas.
[image: Screenshot 2024-11-14 at 1.57.54 PM.png]
On Wed, Nov 13, 2024 at 7:37 PM BelalKhalifaKP ***@***.***>
wrote:
> Absolutely! The magic is in the aspect ratio of the Image. When you have
> an
> Image with a size of 200x300 and you don't set the aspect ratio to 2-3
in
> className or set width and height to 200 and 300 it will be slow. Really
> just resizing Images changes everything. If you wanna display the image
in
> the size 150x250 and set the width and height to 150 and 250 but the
image
> itself has another aspect ratio, you will have problems. Just resize the
> image to a ratio that fits 150-250.
>
> Let me know if this changed your life.
>
> Am Mi., 13. Nov. 2024 um 13:36 Uhr schrieb Ariunaa Myagmar <
> ***@***.***>:
>
> > Were you able to figure this out?
> >
> > —
> > Reply to this email directly, view it on GitHub
> > <
>
#21294 (reply in thread)>,
>
> > or unsubscribe
> > <
>
https://github.com/notifications/unsubscribe-auth/BC7XITKSZWIYREYSEJHC7TD2AMMSXAVCNFSM4WHTLOHKU5DIOJSWCZC7NNSXTOSENFZWG5LTONUW63SDN5WW2ZLOOQ5TCMJSGM3TONJR>
>
> > .
> > You are receiving this because you commented.Message ID: <vercel/next.
> > ***@***.***>
> >
>
> —
> Reply to this email directly, view it on GitHub
> <
#21294 (comment)>,
> or unsubscribe
> <
https://github.com/notifications/unsubscribe-auth/A3OKHR73Y5OPEEGC7CXDR7L2AMTVDAVCNFSM4WHTLOHKU5DIOJSWCZC7NNSXTOSENFZWG5LTONUW63SDN5WW2ZLOOQ5TCMJSGM4DIMZV>
> .
> You are receiving this because you commented.Message ID: <vercel/next.
> ***@***.***>
>
—
Reply to this email directly, view it on GitHub
<#21294 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BC7XITNB6MKU53Q6GVSYQB32AQWDNAVCNFSM4WHTLOHKU5DIOJSWCZC7NNSXTOSENFZWG5LTONUW63SDN5WW2ZLOOQ5TCMJSGQ4TINZR>
.
You are receiving this because you commented.Message ID: <vercel/next.
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Imagine the surprise when I found out the above makes my static site always download a 1.5MB avif at 2x the source resolution marked as a slow request (runs a serverless function?) instead of the 200kb static webp I provided, with I don't understand the defaults here - why is a I can see the more useful usecases in the docs, but when the barebones functionality can set you up for a serious performance hit in what I'd call an elementary usecase then isn't it reasonable to say the component might be defaulting to too many magic assumptions about the platform and srcset generation specifically? |
Beta Was this translation helpful? Give feedback.
-
Not sure if everyone keep having this issue, but I had it and struggle a while with it. export NEXT_SHARP_PATH=$(pwd)/node_modules/sharp Run a build npm run build copy the assets as recommended in the docs. run your server.js node .next/standalone/server.js 1st checkoint: moving on.. moving files to the server. here, whatever you're using it's okey. rsync is my prefer choice for this quick tests. move the output folder into your server. this can be the command you run if you choose rsync: rsync -avz --delete ./.next/standalone/ user@host:/path/to/your/folder Once in the server you can either run it as is with the comand above or I prefer to use systemctl [Unit]
Description=Your awesome project
After=network.target
[Service]
User=your-user
WorkingDirectory=/path/to/your/folder
# Ensure that the production environment is set and NEXT_SHARP_PATH is defined.
Environment="NODE_ENV=production"
Environment="NEXT_SHARP_PATH=/path/to/your/folder/node_modules/sharp"
# If you use nvm, load it (or set the PATH so node can be found)
# just type which node and it should give you the path to put bellow
ExecStart=/path/to/node server.js.
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target save it as whatever server name you want .service inside the sudo systemctl daemon-reload
sudo systemctl restart your-service-name.service
sudo systemctl status your-service-name.service I hope this helps at least 1 person. |
Beta Was this translation helpful? Give feedback.
-
It's not about the server, it's as if nextjs Image renders late. I have found something that works for me though. I got a real low quality of my image, compressed it and converted it to base64 string, then I was able to use it like this:
If you're rendering something like an icon it's best you use @svgr/webpack package for svg's |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am using next/image as described
but its superslow while loading the page

what could be the issue or its expected behaviour because of optimisation on demand ?
Beta Was this translation helpful? Give feedback.
All reactions