Image and Media Asset Budgets
You'll learn how to set hard limits on image, font, and video sizes to prevent your site from ballooning and slowing down.
Why Media Assets Need Budgets
Images, videos, and fonts are often the largest files your users download. A single unoptimized hero image can weigh 3MB, instantly destroying your load time. Just like you set JavaScript bundle budgets, you need clear limits for media assets.
Setting Image Budgets
Define acceptable sizes for different image types:
- Hero images: 200KB max (compressed, modern format)
- Thumbnails: 20KB max
- Icons: 10KB or use SVG
- Background images: 150KB max
Think of this like a weight limit for luggage — every asset must fit the allowance or get optimized.
Font File Budgets
Fonts can quietly consume 100-500KB per weight/style. Budget guidelines:
- Total font weight: 100KB max for all font files combined
- Limit font variants: Only load weights and styles you actually use
- Use modern formats: WOFF2 compresses ~30% better than older formats
Video Considerations
Videos are special — they're huge but often optional:
- Budget for initial load: 0KB (lazy-load or require user interaction)
- If auto-playing: Keep under 500KB or use animated image alternatives
- Streaming video: Doesn't count toward page load budget but monitor bandwidth usage
Enforcing Your Budget
Track total page weight in your monitoring tools. Set alerts when image bytes exceed your threshold, just like you would for JavaScript. Use build tools to automatically reject oversized assets during deployment.
Key Takeaway:
Media asset budgets define maximum acceptable file sizes for images, fonts, and videos, preventing these large resources from destroying your site's performance — treat them with the same discipline as code budgets.