Speed Up Your Website With a CDN and Lazy Loading
-
Home
-
Web Performance
-
Optimizing Website Speed With a CDN and Lazy Loading
Optimizing Website Speed With a CDN and Lazy Loading
How a CDN and native lazy loading speed up your website, which images not to lazy-load, and how to measure the gains in Core Web Vitals.
Last updated: 12 November 2026
A CDN and lazy loading are two of the cheapest ways to make a website faster. A CDN serves your files from servers close to each visitor and caches them, so pages reach the browser sooner. Lazy loading delays images and embeds that are below the fold until the visitor scrolls near them. Used together, and without lazy-loading your main above-the-fold image, they improve Core Web Vitals and how fast your pages feel.
Key takeaways
- Google's "good" Core Web Vitals thresholds are LCP within 2.5 seconds, INP within 200 milliseconds and CLS of 0.1 or less.
- Put static files (images, CSS, JavaScript, fonts) behind a CDN with long cache lifetimes.
- Use native
loading="lazy"for images and iframes below the fold. - Never lazy-load the largest above-the-fold image. Give it
fetchpriority="high"instead. - Always set
widthandheighton images so the layout doesn't jump.
Why does website speed matter?
Slow pages lose visitors before they see your offer, and page experience is part of how Google evaluates pages. Google measures real-user experience with Core Web Vitals:
- Largest Contentful Paint (LCP): how long the main content takes to appear. Good is 2.5 seconds or less.
- Interaction to Next Paint (INP): how quickly the page responds to taps and clicks. Good is 200 milliseconds or less.
- Cumulative Layout Shift (CLS): how much the layout jumps while loading. Good is 0.1 or less.
A CDN mainly helps LCP. Lazy loading helps LCP and data use by cutting what loads up front. Correct image dimensions fix CLS.
How does a CDN speed up a website?
A content delivery network keeps copies of your files on servers around the world. A visitor in Mumbai gets your images from a nearby location instead of from your origin server, which may be in another country. A CDN also absorbs traffic spikes and can compress files and serve modern image formats.
How to set it up well
- Put the whole domain behind the CDN (for example Cloudflare) or serve static assets from a CDN subdomain.
- Cache static files for a long time. For files whose names change on every release (for example
app.3f9a1c.css), sendCache-Control: public, max-age=31536000, immutable. - Be careful with HTML. Many CDNs, including Cloudflare by default, cache files by extension and don't cache HTML. Cache HTML only for pages that are the same for every visitor, and never for logged-in, cart or account pages.
- Purge the cache after each deploy, or version your asset file names so visitors always get the new files.
- Turn on compression (Brotli or gzip) and HTTP/2 or HTTP/3.
How does lazy loading work?
Modern browsers support lazy loading natively. Add one attribute to images and iframes that are below the fold:
<img src="team.webp" alt="Our team at work" width="800" height="533" loading="lazy">
<iframe src="https://www.youtube.com/embed/VIDEO_ID" title="Project walkthrough" loading="lazy"></iframe>
The browser then waits until the visitor scrolls close to these elements before downloading them. That makes the first load lighter, especially on long pages with galleries, maps or video embeds.
Which images should you not lazy-load?
Your hero image or the first large image on the page is usually the LCP element. Lazy-loading it delays it and makes LCP worse. Load it straight away and tell the browser it's important:
<img src="hero.webp" alt="Website development in Pune" width="1200" height="675" fetchpriority="high">
A simple rule: no loading="lazy" on anything visible without scrolling on a typical phone screen.
Other quick wins that work with a CDN
- Modern image formats: WebP or AVIF are usually much smaller than JPEG or PNG.
- Responsive images: use
srcsetandsizesso phones don't download desktop-sized images. - Video: don't autoplay heavy background videos on mobile. Show a lightweight image instead.
- Fonts: use fewer font weights and
font-display: swap. - Third-party scripts: remove unused trackers and widgets, and load chat widgets after the page is interactive.
How do I measure the improvement?
Test key pages in PageSpeed Insights before and after each change. Lab scores show what changed, while the field data (from real Chrome users) is what Google uses for Core Web Vitals. Search Console's Core Web Vitals report groups your URLs by status, so you can track progress across the whole site.
FAQ
Is a CDN useful for a small business website in India?
Yes. Even if most visitors are in India, a CDN serves cached files from nearby locations, reduces load on your hosting and protects against traffic spikes. Many CDNs have free plans.
Does lazy loading hurt SEO?
Native lazy loading with loading="lazy" is fine for search engines, because the image is still in the HTML. Problems come from JavaScript lazy loaders that hide images from crawlers, and from lazy-loading the main above-the-fold image.
Why is my page still slow after adding a CDN?
Usually because of heavy images, render-blocking JavaScript, a slow server response for the HTML itself, or third-party scripts. Check the opportunities listed in PageSpeed Insights.
Do WordPress and Shopify support lazy loading?
Yes. WordPress adds loading="lazy" to images by default, and most Shopify themes lazy-load images below the fold. Check that your theme doesn't also lazy-load the hero image.
Want a faster website?
HMINFOSOFT builds fast, SEO-ready websites and fixes slow ones. Our website development team in Pune can audit your Core Web Vitals and set up your CDN, caching and images properly. Get a free quote.
Sources: web.dev: Web Vitals; web.dev: Browser-level image lazy loading.
Share this post:
Related Posts
A practical checklist to speed up a React website: code splitting, server rendering, images, re-rend...