Karachi, Pakistan Mon–Sat: 10AM–7PM PKT
Home Services
Design & Development
UI/UX Design Web Development WordPress Development Responsive Web Design Corporate Website Landing Pages / Microsites E-Commerce Solutions Mobile App Development
Marketing & Growth
SEO Services Content Marketing Social Media Marketing PPC / Google Ads Branding & Creative Speed & Performance
Hosting & Support
Web Hosting Maintenance & Support
Portfolio
Website Design Logo & Graphics
Clients About Blog Free Tools Get a Quote
SEO & Speed Guide

Lazy Loading Images: How to Do It Right (and What Not to Lazy-Load)

Native lazy loading for images and iframes, why the hero image must load eagerly, lazy backgrounds and video embeds, and how WordPress handles it.

Lazy loading images: images loading as the visitor scrolls down a page

Lazy loading delays downloading images and iframes until a visitor scrolls near them, so the first screen loads faster and mobile data is not wasted on content nobody sees. Modern browsers support it natively with one attribute: loading="lazy". The golden rule is to lazy-load everything below the fold and never the hero or main image at the top, which should load immediately with fetchpriority="high". This guide shows the right markup, how WordPress handles it, how to lazy-load background images and videos, and the mistakes that make pages slower instead of faster.

Key takeaways
  • Use native loading="lazy" on images and iframes below the first screen.
  • Do not lazy-load the LCP image (hero, main product photo). Give it fetchpriority="high".
  • Always include width and height so lazy images do not cause layout shift.
  • Replace heavy video and map embeds with a click-to-load preview.

Native lazy loading: the markup

<!-- Below the fold: lazy -->
<img src="gallery-3.webp" width="800" height="600"
     alt="Finished kitchen project" loading="lazy" decoding="async">

<!-- Embeds below the fold -->
<iframe src="https://www.google.com/maps/embed?pb=..." width="600" height="400"
        loading="lazy" title="Our office location"></iframe>

All modern browsers support loading="lazy" on images, and Chromium and Firefox and Safari support it on iframes. Older browsers simply load the image normally, so there is no need for a JavaScript fallback.

Browsers start loading lazy images before they enter the viewport, using a distance threshold that is larger on slow connections, so visitors rarely see empty boxes when they scroll at a normal speed.

The hero image: load it eagerly and early

The largest image on the first screen is usually the page's Largest Contentful Paint (LCP) element. Lazy-loading it delays LCP, because the browser waits for layout before deciding to fetch it. Mark it as important instead: Also, this matters for lazy loading images on every kind of site.

<img src="hero-1600.webp"
     srcset="hero-800.webp 800w, hero-1600.webp 1600w"
     sizes="100vw" width="1600" height="900"
     alt="Team at work in our Karachi office"
     fetchpriority="high">

If the hero is a CSS background image, the browser discovers it late. Preload it in the head:

<link rel="preload" as="image" href="hero-1600.webp"
      imagesrcset="hero-800.webp 800w, hero-1600.webp 1600w" imagesizes="100vw"
      fetchpriority="high">

Lazy loading images: which images to lazy-load

ImageLazy?
Logo in the headerNo
Hero or banner, main product photoNo, use fetchpriority="high"
Images visible on the first mobile screenNo
Gallery, blog images further down, testimonials, footer badgesYes
Product grid images beyond the first rowYes
Map, YouTube and social embedsYes, or click-to-load

Remember that "above the fold" is different on a phone and a desktop. A product grid showing four items in a row on desktop may show only one on mobile.

Lazy loading images: always reserve space

A lazy image without dimensions has no height until it loads, so content jumps when it appears. Keep width and height attributes on every image and use CSS height: auto for responsiveness. Our CLS guide covers this in detail. So keep this in mind whenever you work on lazy loading images.

Lazy-loading CSS background images

Native lazy loading does not work on CSS backgrounds. Use an IntersectionObserver to add a class when the section approaches the viewport:

<section class="cta-band lazy-bg">...</section>

.cta-band.is-visible { background-image: url(cta-bg.webp); }

const io = new IntersectionObserver((entries) => {
  entries.forEach(e => {
    if (e.isIntersecting) { e.target.classList.add('is-visible'); io.unobserve(e.target); }
  });
}, { rootMargin: '300px' });
document.querySelectorAll('.lazy-bg').forEach(el => io.observe(el));

Lazy loading images: videos and YouTube embeds

A single YouTube embed downloads hundreds of kilobytes of JavaScript even if nobody presses play. Use a "facade": show the thumbnail with a play button, and load the real iframe on click. Libraries such as lite-youtube-embed do this in a few lines, and many WordPress performance plugins have a "YouTube preview image" option.

For self-hosted videos, use preload="none" and a poster image so the file is not downloaded until the visitor plays it.

Lazy loading images: lazy loading in WordPress

  • WordPress adds loading="lazy" to content images and iframes automatically since version 5.5.
  • Since version 6.3 it skips lazy loading for the first large image and adds fetchpriority="high" to the likely LCP image.
  • Page builders and sliders sometimes override this. Check the hero's markup in the page source.
  • Do not stack a JavaScript lazy-load plugin on top of native lazy loading; it adds script and can delay images further.

How to test lazy loading

  1. Open DevTools → Network, filter by "Img", reload and scroll. Lazy images should only appear as you scroll.
  2. Run PageSpeed Insights. "Largest Contentful Paint image was lazily loaded" means you lazy-loaded the hero by mistake.
  3. "Defer offscreen images" means some below-the-fold images are still loading eagerly.

Frequently asked questions

Does lazy loading hurt SEO?

Not with native lazy loading. Googlebot renders pages with a tall viewport and loads lazy images. Problems come from old JavaScript methods that only load images on scroll events.

Should I lazy-load images in the first slide of a slider?

No. Lazy-load only the slides after the first one.

What does decoding="async" do?

It lets the browser decode the image off the main path so it does not hold up other rendering. It is safe on most images.

Related guides: Why Website Speed Matters and How to Make Your Site Faster, How to Get Your Website on Google and 301 vs 302 Redirects.

For official guidance, see web.dev by Google.

Want faster pages?

Our speed optimization service sets up image loading, formats and caching properly. Also see how to compress images and how to convert to WebP.

Written by the ItsWebExpert team, a web design and development company in Karachi building websites, online stores and apps for businesses across Pakistan.

Ask a Question on WhatsApp

Let's Build Your
Next Website

Tell us what you need and we will reply within 24 hours with honest advice and a fixed quote.

Trusted by our clients, rated 5.0 on Google

5.0 11 Google reviews Read all →
I had a great experience working with Waqas and his team. We got some website development and SEO work done, and I'm quite satisfied with the overall results. They understood our requirements, suggested improvements, and handled the work professionally. What I appreciated most was their communication, attention to detail, and willingness to make changes whenever needed. Waqas is very cooperative, and the team knows what they're doing. Definitely a good choice for anyone looking for reliable web development and digital marketing services.
HUHafiz Ubaid Google review · Nov 2026
I was referred to their company by someone, and I'm really glad I connected with them. Waqas, the CEO, is a very humble and professional person who leads his team exceptionally well. Their expertise in digital marketing, web development, and custom development services is impressive. The team is skilled, responsive, and committed to delivering quality work. Had a really positive experience working with them. Highly recommended!
MRMuhammad Rafeeq Google review · Nov 2026
I had hired them for my client's task of Custom Wordpress plugin development. and many other tasks later on.. Waqas is super fast and sharp.. I know him since 2019.. I really really appreciate his work. Highly recommended..
RFRaheela Farooqui Google review · Nov 2026
I had a positive experience working with Waqas and his team. They provided excellent support with graphic design and social media management. The team was professional, responsive, and attentive to our needs. They understood our vision and delivered quality work on time. Highly recommended for anyone looking for creative and reliable digital services.
URUsman Rock Google review · Nov 2026
I really appreciate their dedication and professionalism. They have a good understanding of SEO, social media marketing, and online brand growth. Communication is smooth, and the quality of work is impressive. Definitely a great team to work with!
SSSameer Sarafaraz Google review · Nov 2026
I've had a great experience working with their team. They understand digital marketing very well and know how to improve online visibility through effective SEO and marketing strategies. Professional, responsive, and reliable. Highly recommended! 🙌❤️
MNMohammad naveed Google review · Nov 2026
I had a really good experience with web Experts. Everything was easy to understand, well-organized, and user-friendly. I appreciate the effort and attention to detail that has gone into creating this platform. It was a smooth and pleasant experience, and I would definitely recommend it to others. Keep up the great work!
SSShazia shaikh Google review · Nov 2026
Extremely professional and committed I am Extremely happy to work with them I wish them best of luck Best Regards M. Salman Farooqui
SFSalman Farooqui Google review · Nov 2026
Outstanding experience! Quality, professionalism, and customer service are all excellent. Keep up the great work!
ARabdul rehman Google review · Nov 2026
Excellent service and a great experience. The team is professional, helpful, and dedicated. Highly recommended!
MEmustafa emb Google review · Nov 2026