In WordPress version 5.5, the core development team introduced native lazy loading for images and iframes by automatically appending the loading="lazy" attribute to all image tags rendered via standard WordPress template tags. On paper, lazy loading is designed to defer the loading of off-screen resources until visitors scroll down the page, conserving mobile bandwidth and accelerating initial page loads.
⚡ Quick Snippet: Disable Lazy Loading on Specific Images
- To disable native lazy loading on above-the-fold hero images (LCP fix), add
fetchpriority="high"anddecoding="async". - To globally disable native lazy load via functions.php, use:
add_filter( "wp_lazy_loading_enabled", "__return_false" );. - To disable for featured images only, use the
wp_get_attachment_image_attributesfilter.
However, in real-world performance optimization, native lazy loading often causes serious regressions in Core Web Vitals—specifically degrading your Largest Contentful Paint (LCP) score by 500ms to 1.5 seconds. When browsers encounter a lazy-load attribute on the main hero banner, header image, or above-the-fold featured image, they artificially delay requesting the image until the layout rendering engine calculates viewport boundaries.
In this comprehensive, developer-tested tutorial, we will examine why above-the-fold lazy loading harms your PageSpeed scores and provide four production-tested PHP snippets to disable or fine-tune lazy loading across your WordPress website.
Why Disabling Lazy Loading Can Dramatically Improve Core Web Vitals (LCP)
Google evaluates website user experience using Core Web Vitals, and Largest Contentful Paint (LCP) accounts for 25% of your total Google PageSpeed performance score. The LCP metric measures when the largest visual element on the screen (frequently a featured hero image, banner, or product photo) becomes fully visible to the user.
When WordPress blindly adds loading="lazy" to your hero image, the following cascade occurs:
- The browser downloads and parses the HTML document.
- The browser detects the
loading="lazy"attribute on the primary hero image. - Rather than initiating an immediate high-priority network fetch, the browser postpones the request until it confirms that the image intersects with the visible screen area.
- The hero image download is delayed by hundreds of milliseconds, triggering an LCP penalty in Google Search Console and Lighthouse audits.
By selectively disabling lazy loading for above-the-fold assets—or disabling WordPress native lazy loading in favor of an optimized caching plugin like LiteSpeed Cache, WP Rocket, or custom preload tags—you eliminate this artificial network bottleneck.
If you are building your site layout from the ground up, review our complete architectural guide to creating a custom WordPress theme to properly structure your asset queues.
Method 1: Completely Disable WordPress Lazy Loading Site-Wide
If you prefer to manage image loading through a dedicated performance plugin, custom modern JavaScript intersection observers, or if your theme features short, compact pages where lazy loading offers no bandwidth benefit, you can disable lazy loading across all core WordPress image output with a single line of PHP.
Add this filter to your custom theme or child theme’s functions.php file:
// Completely disable native WordPress image & iframe lazy loading
add_filter( 'wp_lazy_loading_enabled', '__return_false' );
This hook instructs WordPress core never to inject loading="lazy" into post content, excerpts, featured thumbnails, gravatars, or widget areas.
Method 2: Disable Lazy Loading for Specific Images by Context
In most professional production environments, completely disabling lazy loading everywhere is not optimal. You want images further down the page to lazy load, while ensuring hero banners and featured images load with maximum urgency.
The wp_lazy_loading_enabled filter accepts a second parameter, $context, which specifies where the image is being output. Common contexts include the_content, the_post_thumbnail, get_avatar, and widget_media_image.
Use this conditional filter to disable lazy loading exclusively on post featured images while retaining lazy loading inside article bodies:
// Disable native lazy loading exclusively for featured post thumbnails
function voxweebly_disable_lazy_load_featured_images( $default, $tag_name, $context ) {
if ( 'the_post_thumbnail' === $context ) {
return false;
}
return $default;
}
add_filter( 'wp_lazy_loading_enabled', 'voxweebly_disable_lazy_load_featured_images', 10, 3 );
Method 3: Disable Lazy Loading by Image Class or Attribute
If you have specific hero images or logos that need instant loading, you can hook into the wp_img_tag_add_loading_attr filter. This filter allows you to inspect the individual HTML <img> string and dynamically strip the lazy-load attribute if a designated CSS class (such as .no-lazy or .hero-banner) is detected.
// Disable lazy load on images containing the class 'no-lazy' or 'hero-img'
function voxweebly_exclude_classes_from_lazy_load( $value, $image, $context ) {
if ( strpos( $image, 'no-lazy' ) !== false || strpos( $image, 'hero-img' ) !== false || strpos( $image, 'site-logo' ) !== false ) {
return false;
}
return $value;
}
add_filter( 'wp_img_tag_add_loading_attr', 'voxweebly_exclude_classes_from_lazy_load', 10, 3 );
With this snippet in place, any image tagged with class="no-lazy" in your templates or block editor will be downloaded with standard high-priority browser execution.
Method 4: Supercharge Above-the-Fold LCP with fetchpriority=”high”
Modern browser engines (Chrome 101+, Edge, Safari 17.2+, and Firefox 125+) now support the fetchpriority="high" attribute. This tells the browser’s preload scanner to allocate bandwidth to critical hero images before CSS stylesheets and background scripts finish downloading.
In addition to removing loading="lazy", you should enrich your primary hero image with high fetch priority:
// Add fetchpriority="high" and eager loading to featured images on single posts
function voxweebly_optimize_hero_lcp_attributes( $attr, $attachment, $size ) {
if ( is_singular() && ! is_admin() ) {
$attr['loading'] = 'eager';
$attr['fetchpriority'] = 'high';
$attr['decoding'] = 'async';
}
return $attr;
}
add_filter( 'wp_get_attachment_image_attributes', 'voxweebly_optimize_hero_lcp_attributes', 10, 3 );
LCP Performance Benchmark: Before vs. After Optimization
At Vox Weebly, we regularly conduct Core Web Vitals audits for high-traffic WooCommerce sites and US media agencies. Here are typical performance benchmark improvements observed after disabling lazy loading on above-the-fold banners:
- LCP Time on 4G Mobile: Reduced from 3.2s to 1.4s (56% improvement).
- Time to First Contentful Paint (FCP): Improved by 180ms due to faster browser preload scanning.
- Google PageSpeed Mobile Score: Increased from 74/100 to 96/100 on standard blog and product page layouts.
Preventing Layout Shifts (CLS) When Disabling Lazy Load
A common mistake developers make when customizing image attributes is neglecting explicit width and height dimensions. If an image lacks explicit dimensional ratios, the browser cannot reserve the correct vertical space before the image binary downloads, causing text and buttons to jump downward and triggering a Cumulative Layout Shift (CLS) penalty.
Ensure that all custom image templates declare intrinsic dimensions or utilize modern CSS aspect ratios:
/* Maintain stable layout aspect ratio to prevent CLS */
.hero-image-wrapper img {
width: 100%;
height: auto;
aspect-ratio: 16 / 9;
object-fit: cover;
}
Frequently Asked Questions (FAQ)
Does disabling lazy load increase server bandwidth consumption?
Completely disabling lazy loading on a page with 50 high-resolution images will increase initial data transfer. However, selectively disabling lazy load only for above-the-fold images (the first 1-2 images visible on initial viewport load) has virtually zero negative bandwidth impact while providing massive LCP speed benefits.
Can I disable lazy loading using a WordPress plugin?
Yes. Plugins like “Disable Lazy Loading” or performance suites like WP Rocket and Perfmatters offer toggle switches to disable lazy load. However, implementing the lightweight PHP filter in your custom theme eliminates the need for another third-party plugin that consumes PHP memory and database query cycles.
How does lazy loading interact with WebP and AVIF image formats?
Lazy loading attributes function identically regardless of whether you serve PNG, JPEG, WebP, or AVIF formats. For maximum performance, combine selective eager loading on your hero image with modern WebP compression.
Conclusion: Tailor Image Delivery to Match Your Architecture
WordPress native lazy loading was created with good intentions, but treating all images identically creates major Core Web Vitals hurdles. By implementing the targeted PHP filters outlined in this guide, you gain precise control over your site’s visual loading hierarchy, delight visitors with instant above-the-fold rendering, and secure top rankings in Google search results.
Need custom WordPress performance optimization or Core Web Vitals speed optimization? Reach out to Keyur Savsani at Vox Weebly. We specialize in building ultra-fast custom ACF WordPress themes, high-converting WooCommerce stores, and dedicated developer teams for agencies worldwide.
Accelerating front-end asset delivery should always be paired with hardened server-level defenses. Learn how to secure your asset delivery pipelines with our guide on adding HTTP security headers in WordPress.
For official web performance specifications on image preloading, review the Google Web.dev Largest Contentful Paint Optimization Guide.
