The number of times I have audibly gasped this morning learning about inefficiencies in Next.js’ <Image> component has made me realize that I’m a little out of shape.
21 replies
@zachleat are you gasping, or is that sound of pieces of you dying inside?
@zachleat there should be an additional category on https://images.tooling.report/
@zachleat Would you mind sharing any examples? No problem if you don't want to support Vercel/Next free of charge, or don't have time, but I use Next at work and would be open to making a PR with improvements for my team/product's sake (and my own satisfaction with our performance)
@philw_ just working on some Eleventy Image comparisons, will probably highlight some of these at 11ty Conf. The biggest ones are: 1. the DX of requiring a static import for the image or you’ll need to specify a width/height. 2. The valid image widths are hardcoded as global configuration and not specific to the width you specify for the image (if I want my image to render 129px, it returns a 256px image on 1.0 DPR screen) 3. The classic complaint about unnecessary content-negotiation.
@zachleat it is very bad! I dislike it! Very much!!!
@eeeps …say more 😅
@zachleat Here's an (official?) demo I was looking at a few weeks ago: https://nextjsconf-pics.vercel.app
The hardcoded list of srcset breakpoints kills me. You're taking an image, asking Cloudinary to resize it to w_720, and then downsizing it to 256w, 384w, and 640w (fine) but then serving it, as-is (at least they don't upscale!), under different URLs, as the 750w, 828w, 1080w, 1200w, 1920w, 2048w, and 3840w versions. Lots of useless load events, cache entries/misses, & WILD .naturalWidths result.
@zachleat https://nextjs.org/docs/pages/api-reference/components/image#devicesizes lets you override that list, but wow, bad name! Misleading documentation! Bad framing!
I'm glad they give you a per-component way to specify `sizes` (via `imageSizes`), and they try to explain it in the docs, but I wish they did more to help here (especially in lazy contexts), because this is the hardest problem in respimg.
I'm not sure why they are always setting decoding=async but whatever can't hurt lol.
@eeeps that demo mixing cloudinary and next image middleware is… something! Looks like the images only render ~485 max width too