Blog
Image optimisation
Posts about Image optimisation.
-
How to compress an image to a target file size in the browser with the Canvas API
A DEV Community guide shows how to shrink a photo to a set size, such as 50 KB, in the browser by searching for the best JPEG quality setting.
-
Site audit finds the srcset habit misses the real image problems
A DEV Community audit of one production site found lazy loading, screen maths and file format mattered more than adding srcset to every image.
-
How to compress a JPG to an exact file size in the browser
A DEV Community post explains how to hit a strict KB limit for a JPEG using a browser search of quality and size, and why '50 KB' has two meanings.
-
Auto-orient photos before resizing, or thumbnails can end up sideways
A DEV Community test shows that resizing phone photos without applying their EXIF orientation tag produces sideways thumbnails with the wrong dimensions.
-
A PNG saved with a .webp filename cost one services page 441 KiB on mobile
A site owner found a PNG disguised as WebP, rebuilt it as a real WebP, and lifted a mobile PageSpeed score from 72 to 85, per DEV Community.
-
A five-step order for fixing Core Web Vitals on a marketing site
A DEV Community post sets out five fixes for slow marketing sites, from measuring first to the largest image, blocking scripts, layout shifts and interaction.
-
Landing page photos were JPEGs renamed .webp, and two went to visitors at full size
A DEV Community post details three JPEGs renamed .webp, mislabelled by the server, and two served unoptimised through CSS backgrounds at 1.87 MB.
-
Next.js image defaults allow 15 widths, one quality and no AVIF unless you change them
A DEV Community post probes the default Next 16.2.7 image endpoint and finds fixed widths, one quality, WebP only and a revalidating cache header.
-
Convert CMYK JPEG uploads to sRGB with sharp, not with a formula
A DEV Community test shows sharp converts CMYK JPEGs to sRGB by default, while the common one-line pixel formula gets colours badly wrong.
-
Developer guide: choosing and shipping business website images that stay fast
DEV Community guide covers picking real photos, sizing, WebP, compression, alt text, licensing and responsive image code for faster business sites.
-
Linear light resampling keeps detail but can cost shadow accuracy, tests show
A DEV Community author tested linear light resizing on a photo and found it keeps more detail but loses shadow accuracy, banding risk and sharpening quality.
-
Which product grid images should never be lazy loaded, according to DEV Community
A DEV Community post explains which images on store pages should load straight away, and which can wait until the visitor scrolls.
-
AVIF first, WebP as fallback is the advice for image-heavy product pages
A DEV Community post says image-heavy sites should serve AVIF first with WebP as fallback, and test both formats on their own fine-texture images.
-
Re-encoding a JPEG in a browser canvas can make the file bigger, tests show
Tests of 25 photos found canvas re-exports at JPEG quality 0.92 grew some files in all three browser engines, and size targets did not prevent it.
-
Reserve space for images before they load to stop text jumping
DEV Community explains how width and height attributes let browsers reserve room for a photo, so text below it stays put while the file downloads.