What Happens When You Type a URL and Press Enter
DNS lookups, TCP and TLS handshakes, HTTP requests, servers, and the browser's rendering pipeline. The whole journey of a web page, explained so it finally clicks.
Read →Images are usually the heaviest part of a page. Formats, sizing, responsive images, lazy loading, the LCP image and layout shift: a practical checklist for fast pages that still look great.
On most websites, images make up more bytes than anything else: more than HTML, CSS and JavaScript combined. That makes them the biggest, easiest performance win available. You can usually cut image weight dramatically without anyone noticing a drop in quality.
| Format | Use for |
|---|---|
| AVIF | Photos and complex images; often the smallest files |
| WebP | Photos and graphics; excellent support, great compression |
| JPEG | Fallback for photos |
| PNG | Images needing lossless quality or simple transparency, when WebP isn't an option |
| SVG | Logos, icons and simple illustrations; tiny and sharp at any size |
Modern browsers support WebP and AVIF. If you need fallbacks, the <picture> element lets the browser choose:
<picture>
<source srcset="hero.avif" type="image/avif">
<source srcset="hero.webp" type="image/webp">
<img src="hero.jpg" alt="Team working around a table" width="1200" height="800">
</picture>
Shipping a 4000-pixel photo into a 400-pixel card is the most common image mistake. Resize images to the sizes they're actually displayed at, accounting for high-density screens (roughly 2× the CSS size is plenty).
srcset and sizes let the browser pick the best file for the device:
<img
src="card-800.webp"
srcset="card-400.webp 400w, card-800.webp 800w, card-1200.webp 1200w"
sizes="(min-width: 1024px) 33vw, (min-width: 640px) 50vw, 100vw"
alt="Product photo"
width="800" height="600"
loading="lazy">
sizes tells the browser how wide the image will be in the layout, so a phone downloads the 400px version and a large desktop the 1200px one.
Give every image width and height attributes (or a CSS aspect-ratio). The browser reserves the right space before the image loads, which prevents content jumping around: a big part of the layout shift (CLS) metric. (Core Web Vitals diagnosis.)
<img src="photo.webp" loading="lazy" alt="..." width="800" height="600">
Native lazy loading defers offscreen images until users scroll near them. But don't lazy load the main image at the top of the page. It's often the Largest Contentful Paint (LCP) element, and lazy loading delays it. Do the opposite for that one:
<img src="hero.webp" fetchpriority="high" alt="..." width="1600" height="900">
If the hero is a CSS background, the browser discovers it late; consider an <img> instead, or preload it.
For photos, quality settings around 70 to 80 usually look identical to the original at a fraction of the size. Compare visually at actual display size. Tools like Squoosh are great for one-off images; build pipelines and image libraries like sharp handle it automatically. (Free tools.)
Many frameworks include an image component that resizes, converts formats, sets dimensions and lazy loads automatically. Image CDNs and many hosting platforms can transform images on the fly through URL parameters. Either saves you from managing dozens of variants by hand.
Photos from cameras and phones carry EXIF metadata (camera details and sometimes GPS location). Stripping it saves bytes and protects privacy, which matters especially for user uploads. (Secure file uploads.)
Use content-hashed filenames and long-lived caching headers, so returning visitors don't download images again. (Caching strategies.)
Not a performance tip, but just as important. Alt text makes images accessible to screen reader users and helps search engines understand them. Describe what matters in context; use alt="" for purely decorative images. (Accessibility basics.)
srcset and sizeswidth and height set on every imageloading="lazy" below the fold, fetchpriority="high" on the heroAVIF and WebP give the best compression for photos and most graphics, with JPEG as a fallback. Use SVG for logos, icons and simple illustrations.
No. Lazy load images below the fold, but load the main above-the-fold image eagerly, ideally with fetchpriority="high", because it often determines Largest Contentful Paint.
Set width and height attributes or a CSS aspect-ratio on every image so the browser reserves the correct space before the image loads.
DNS lookups, TCP and TLS handshakes, HTTP requests, servers, and the browser's rendering pipeline. The whole journey of a web page, explained so it finally clicks.
Read →There are dozens of HTTP status codes, but about fifteen cover nearly everything. What each one means, when to return it, and the mix-ups (401 vs 403, 301 vs 302) that confuse everyone.
Read →A, AAAA, CNAME, MX, TXT and NS records in plain English, why DNS changes seem slow, and the troubleshooting commands that tell you what is really going on.
Read →