How to Lazy Load SVG — Performance Optimization Guide
Lazy load SVG files to improve page performance — native lazy loading, Intersection Observer for inline SVG, and dynamic import patterns in JavaScript frameworks.
Drop your image here
Supports PNG, JPG, BMP, WEBP up to 5MB
Native Lazy Loading for SVG img Elements
SVG images referenced with `<img>` tags support the native `loading='lazy'` attribute in all modern browsers. The browser defers loading the SVG until it approaches the viewport during scroll. This is the simplest lazy loading approach with zero JavaScript required.
- `<img src='illustration.svg' loading='lazy' alt='Description'>`
- Works in Chrome 77+, Firefox 75+, Edge 79+, Safari 15.4+
- No lazy loading for inline SVG — the SVG is already in the HTML
Intersection Observer for SVG Animation Triggers
Use the Intersection Observer API to trigger SVG animations only when the SVG enters the viewport. Create an observer that watches SVG elements and adds a CSS class or triggers GSAP animations when they intersect. This prevents off-screen SVG animations from playing before the user sees them.
- Create IntersectionObserver with `{ threshold: 0.1 }` for 10% visibility trigger
- On intersection: add class or call GSAP play() to start the animation
- Disconnect observer after first trigger for `once: true` behavior
Frequently Asked Questions
Should I lazy load SVG icons on a website?
For icons in the critical viewport (header, nav), no — eager loading is better for LCP. For icons far down the page (footer icons, illustration SVGs in lower page sections), native loading='lazy' is appropriate. For inline SVG icon sprites, the entire sprite loads once — no lazy loading needed or beneficial.
How do I lazy load inline SVG in React?
Use React.lazy() with dynamic import: `const SVGComponent = React.lazy(() => import('./illustration.svg?react'))`. Wrap with `<Suspense fallback={<div>Loading...</div>}>`. The SVG component loads only when it's rendered, deferring the parse and render until needed.
Related guides
Ready to Convert Your Image to SVG?
Free online converter — no sign-up, no watermarks, results in under 3 seconds.
Try It Free — Convert Image to SVG