[Feature Request] Image component downloads images twice when using NextImage #4690
Replies: 5 comments
-
@RnbWd Can you create a fiddle out of this and provide a link here? |
Beta Was this translation helpful? Give feedback.
-
I can try to create a fiddle with it, I'll probably try linking it directly to the images from the site I'm building so the next optimized images are displayed alongside the pngs |
Beta Was this translation helpful? Give feedback.
-
@jrgarciadev Is it ok if I take this up? |
Beta Was this translation helpful? Give feedback.
-
Also facing the same issue, would be good to get a solution here. |
Beta Was this translation helpful? Give feedback.
-
@wingkwong |
Beta Was this translation helpful? Give feedback.
-
Using
next/image
with NextUI's Image component does not utilize Next's image optimizationCurrently, if you embed Next's
Image
component (next/image
) inside of NextUI'sImage
component, it downloads the original src image file, and also displays a loading screen until the original image is loaded in the browser. Here's example code:The issue is that the original src file,
banner.png
, is never displayed in the browser, but it's still being downloaded, and the skeleton is shown until the original image is downloaded. In my example app, I have about 20 images, and each png image is about 150kb. The loading process can be very slow, sometimes taking more than a minute for the image skeletons to disappear. However, the image that is actually shown in browser is the optimized webp or avif file, which is less than 5kb. So the Image skeleton is still shown even though the final image has already been downloaded.Describe the solution you'd like
It would be nice if NextUI's image component could only download the optimized image, instead of the original src. I'm not quite sure how
next/image
handles the src file, but the source image is different once the component is mounted, and NextUI begins downloading the original src before NextImage updates the src prop.Describe alternatives you've considered
Using
next/image
alone solves the issue, only downloading the optimized files. It should also be possible to copy the optimized image url directly, but I haven't tried that method yet. The optimized image url looks something like:_next/image?url=%2Fbanners%2FBanner.png&w=1080&q=75
Screenshots or Videos
No response
Beta Was this translation helpful? Give feedback.
All reactions