Skip to main content

Overview

Efficient asset management improves app performance and reduces bundle size. This guide covers asset optimization, loading strategies, and best practices.

Asset Types

Images

Fonts

Videos

Audio

Project Structure

Image Optimization

Image formats

Best for photos with transparency:
Pros:
  • 25-35% smaller than PNG/JPG
  • Supports transparency
  • Good quality
Cons:
  • Not supported in very old devices

Image dimensions

Responsive images

components/ResponsiveImage.tsx

expo-image

Use expo-image for better performance:
Features:
  • Native caching
  • Smooth transitions
  • Blurhash placeholders
  • Better performance
  • WebP support

Image Caching

Preload images

hooks/usePreloadImages.ts
Usage:

Clear cache

Blurhash Placeholders

Generate blurhash:

Font Management

Load fonts

app/_layout.tsx

Use fonts

Font variants

Instead of multiple font files:
Configure in app.json:

Asset Bundling

app.json configuration

app.json
This ensures all assets in assets/ are bundled with your app.

Exclude assets

Remote Assets

CDN strategy

utils/cdn.ts

Progressive loading

components/ProgressiveImage.tsx

Asset Optimization Tools

ImageOptim (macOS)

Sharp (Node.js)

scripts/optimize-images.js

FFmpeg (Video)

Vector Graphics

React Native SVG

components/Logo.tsx
Benefits:
  • Scales perfectly
  • Small file size
  • Customizable colors
  • No multiple resolution files needed

Asset Security

Protect sensitive assets

Watermarking

Best Practices

General

  • Optimize before adding: Compress images before committing
  • Use appropriate formats: WebP for photos, PNG for graphics, SVG for icons
  • Lazy load: Load assets when needed, not upfront
  • Cache aggressively: Use expo-image caching
  • CDN for large assets: Host videos and large images on CDN
  • Version assets: Add version/hash to remote asset URLs for cache busting

Images

  • Multiple resolutions: Provide @2x and @3x variants
  • Responsive sizing: Load appropriate size for display dimensions
  • Compression: Balance quality vs file size (80-85% quality is usually good)
  • Dimensions: Don’t load 4K images for thumbnails

Fonts

  • Load only what you use: Don’t load all font weights
  • System fonts: Consider using built-in system fonts
  • Subset fonts: Remove unused glyphs for smaller file size

Troubleshooting

  • Check file path is correct
  • Verify image is in assetBundlePatterns
  • Clear Metro cache: npx expo start --clear
  • For remote images, check URL is accessible
  • Ensure fonts are loaded before rendering
  • Check font family name matches loaded font key
  • Rebuild app after adding new fonts
  • Analyze assets with npx expo-atlas
  • Compress images with tools like ImageOptim
  • Use WebP format
  • Move large assets to CDN
  • Preload critical images
  • Use appropriate image sizes
  • Enable caching with expo-image
  • Consider using progressive loading

Asset Checklist

  • All images compressed and optimized
  • Using WebP format where appropriate
  • Multiple resolutions provided (@1x, @2x, @3x)
  • Images are appropriate size for display
  • Fonts loaded before app renders
  • Only necessary fonts included
  • Large assets hosted on CDN
  • Asset caching configured
  • Placeholders for images
  • SVG used for icons where possible