# Images, Fonts and Critical Rendering Path

> Serve responsive modern images, load fonts without layout shift, and prioritise the resources needed for the first paint. Free notes, key concepts, resources...

Canonical: https://www.internhack.in/roadmaps/tracks/frontend/asset-optimization
Last updated: 2026-11-28

Serve responsive modern images, load fonts without layout shift, and prioritise the resources needed for the first paint.

Intermediate · about 4 hours · difficulty 3/5

Learn first: [Core Web Vitals and Performance Metrics](https://www.internhack.in/roadmaps/tracks/frontend/core-web-vitals)

Images are usually the heaviest bytes on a page, and the LCP element is an image on most sites. Fonts and CSS block text from appearing. Getting these right is often the quickest performance win.

### Images

- Use modern formats: **AVIF** or **WebP** with fallbacks via `<picture>`.
- Serve the right size with `srcset` and `sizes` so phones do not download desktop images.
- Always set `width` and `height` (or `aspect-ratio`) to prevent layout shift.
- `loading="lazy"` for below-the-fold images, but **never** lazy-load the LCP image. Give the hero image `fetchpriority="high"`.
- Use SVG for icons and logos, and an image CDN or framework image component (Next.js `<Image>`) to automate resizing.

### Fonts

- Prefer **WOFF2**, subset to the characters you need, and self-host or use a reliable provider.
- `font-display: swap` shows fallback text immediately; tune fallback metrics (`size-adjust`) to reduce the shift when the web font arrives.
- Preload the one or two most important font files; use fewer weights, or a variable font.
- System font stacks cost nothing.

### Critical rendering path

- CSS is **render-blocking**: keep critical CSS small, inline it if needed, and load the rest efficiently.
- Put non-critical scripts behind `defer`.
- Use `preconnect` for important third-party origins.
- Reduce request chains: the browser should discover the LCP resource in the initial HTML, not after JavaScript runs.

### Good enough to move on

You can turn a page with a large hero image and custom fonts into one with a fast LCP and near-zero CLS, and explain each change using the Network and Performance panels.

## Key concepts

- **Modern image formats: AVIF and WebP**
- **Responsive images with srcset and sizes**
- **Lazy loading and fetchpriority**
- **Preventing layout shift**
- **Web font loading and font-display**
- **Render-blocking CSS and critical CSS**
- **preconnect and preload hints**
- **Image CDNs and framework image components**

## Mini project

Optimise a landing page: convert images to AVIF/WebP with srcset, fix the LCP image priority, add dimensions everywhere, subset and preload the main font, and bring CLS below 0.05.

## Check yourself

Why does adding loading="lazy" to the hero image make LCP worse?

## Free resources

- [Optimize Largest Contentful Paint](https://web.dev/articles/optimize-lcp) (web.dev)
- [Responsive images](https://developer.mozilla.org/en-US/docs/Web/HTML/Guides/Responsive_images) (MDN)
- [Best practices for fonts](https://web.dev/articles/font-best-practices) (web.dev)

Previous: [JavaScript Loading and Runtime Performance](https://www.internhack.in/roadmaps/tracks/frontend/javascript-performance) · Next: [HTTP Caching, Compression and CDNs](https://www.internhack.in/roadmaps/tracks/frontend/caching)

## More in Web Performance

- [Core Web Vitals and Performance Metrics](https://www.internhack.in/roadmaps/tracks/frontend/core-web-vitals)
- [JavaScript Loading and Runtime Performance](https://www.internhack.in/roadmaps/tracks/frontend/javascript-performance)
- [Images, Fonts and Critical Rendering Path](https://www.internhack.in/roadmaps/tracks/frontend/asset-optimization)
- [HTTP Caching, Compression and CDNs](https://www.internhack.in/roadmaps/tracks/frontend/caching)
- [Profiling with Lighthouse and DevTools](https://www.internhack.in/roadmaps/tracks/frontend/performance-tooling)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Frontend Developer Roadmap](https://www.internhack.in/roadmaps/tracks/frontend)
