Replies: 5 comments 3 replies
-
We experienced a pretty severe degradation in image optimization performance. We're actually looking at 3rd party optimizers to use via loaders instead of the built in optimizer. Would definitely support this option to return to sharp based optimizer instead. |
Beta Was this translation helpful? Give feedback.
-
Hello, I'm experiencing same issue. I've downgraded nextjs but a solution to this huge problem would be nice, your proposal seems to be a good idea ! |
Beta Was this translation helpful? Give feedback.
-
Hi, we planning to use Next Image in production using Next JS 11, but the first time loading seems to be too slow (at least a few seconds), even using the examples in localhost, it is the same as well. Hopefully we have a resolution for this. Reference: Image component |
Beta Was this translation helpful? Give feedback.
-
For those following along, @atcastle has opened a PR that was merged at #27346 🎉🎉 (already released in As for non-canary versions, may be out in |
Beta Was this translation helpful? Give feedback.
-
The problem is not many people actually know that this is included in 11 |
Beta Was this translation helpful? Give feedback.
-
Update: This has shipped! Run
npm install next@latest sharp
to start using Sharp as the default.What I'm proposing:
Why I'm proposing this
Sharp is a lot faster than Squoosh for this use case. This fact has been noticed by the community since Next.js moved from Sharp to Squoosh, and is an ongoing source of complaints. Some users say this is preventing them from using the image component entirely.
We have no reason to believe that Squoosh will be competitive with Sharp for this use case in the near future.
The two reasons Next.js switched to Squoosh are both addressed by this solution:
How I propose to do this
I propose a solution that checks for the availability of Sharp at server startup using something like this:
We would also do a similar check during SSR or SSG, as part of the default loader provided with the image component. The default loader is what integrates with the image optimizer, so If that loader is called during production, and sharp is not installed, we can log a warning message on the server such as the following:
WARNING: For production image optimization with Next.js, the optional 'sharp' package is strongly recommended. Run 'yarn add sharp' or install sharp globally, and Next.js will use it automatically for image optimization.
The Squoosh code will continue to exist in the Next.js codebase, as it is adequate for a development server use case (though even in that context, Sharp will be used if it available).
The Sharp integration code (similar to what was removed in this PR) will be added back into the codebase, to make use of the Sharp library if it is available.
Beta Was this translation helpful? Give feedback.
All reactions