Get a quote on WhatsApp in 2 min
Contact

Mexico City, Mexico
Available for remote and on-site projects.

Professional networks

LinkedIn · GitHub · Email
Applied engineering, measurable results.

Optimizing Core Web Vitals in WordPress for SEO

· 5 min read · Samuel Torres

To pass Core Web Vitals in WordPress, 75% of real visits need LCP ≤ 2.5 s, INP ≤ 200 ms and CLS ≤ 0.1. Most failures start on the server and in third-party scripts, not the theme. On one site I run, server-level caching cut the Home's p95 response from 2.6 s to 20 ms.

Understanding Core Web Vitals Metrics

Core Web Vitals: three field metrics Google uses to describe loading, responsiveness and visual stability, judged at the 75th percentile of real visits (web.dev).

  • LCP (Largest Contentful Paint): when the largest image, text block or video in the viewport finishes rendering. Good is 2.5 s or less; poor is above 4.0 s (web.dev). LCP includes server response time, so a slow TTFB is already a slow LCP.
  • INP (Interaction to Next Paint): how long the page takes to paint after a click, tap or key press, across the whole visit. Good is 200 ms or less. INP replaced FID as a Core Web Vital on March 12, 2024 (web.dev).
  • CLS (Cumulative Layout Shift): how much the content jumps while it loads. Good is 0.1 or less.

One distinction saves weeks: Lighthouse is a lab test; Core Web Vitals are field data. A Lighthouse score is a diagnosis on one machine. The pass/fail that matters is the 75th percentile of real visits.

This script reads that field data for every site in a list from the Chrome UX Report (CrUX) API. It only reads; it touches nothing in production:

#!/usr/bin/env bash
# p75 field data (what real visitors get), not a lab score.
# Mobile first: that is where WordPress sites usually fail.
KEY="$CRUX_API_KEY"   # from the environment, never hard-coded in the repo
while read -r origin; do
  curl -s "https://chromeuxreport.googleapis.com/v1/records:queryRecord?key=$KEY" \
    -H 'Content-Type: application/json' \
    -d "{\"origin\": \"$origin\", \"formFactor\": \"PHONE\"}" |
  jq -r --arg o "$origin" '[$o, .record.metrics.largest_contentful_paint.percentiles.p75,
        .record.metrics.interaction_to_next_paint.percentiles.p75,
        .record.metrics.cumulative_layout_shift.percentiles.p75] | @tsv'
done < sites.txt   # small sites without enough traffic return no CrUX record

Optimizing WordPress for Core Web Vitals

LCP: the server first, then the hero image

If PHP builds every page on every visit, no image trick saves the LCP. On the Conqr site (WordPress, Elementor Pro and Polylang), the jump came from the server, not from a plugin: PHP-FPM, a 256 MB OPcache, a dedicated Redis and a page cache that Apache serves without touching PHP. The Home went from 3.99 to 766 requests per second with 10 users, and its p95 response time from 2.6 s to 20 ms.

⚠️ This changes PHP on a production server. Copy the current file first (cp file.ini file.ini.bak), apply the change in a low-traffic window, and roll back by restoring the copy and restarting PHP-FPM.

# EasyApache 4 (cPanel): a separate .ini so a PHP update never overwrites it.
# 256 MB fits the compiled PHP of WordPress + Elementor + plugins with headroom;
# when OPcache runs out it starts recompiling, and TTFB climbs again.
cat > /opt/cpanel/ea-php83/root/etc/php.d/zz-rendimiento.ini <<'EOF'
opcache.enable=1
opcache.memory_consumption=256
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=20000
EOF
/scripts/restartsrv_apache_php_fpm   # reload PHP-FPM so the new limits apply

Then the hero image. The element that becomes the LCP must never be lazy-loaded, and the browser should fetch it before scripts and fonts:

<?php
// mu-plugins/cwv-hero.php — on most pages the hero image IS the LCP element.
// Lazy-loading it delays the metric Google grades; giving it high priority
// lets the browser fetch it ahead of scripts and fonts.
add_filter('wp_get_attachment_image_attributes', function ($attr, $attachment) {
    if (get_post_meta($attachment->ID, '_cwv_hero', true)) {  // the editor marks the hero once
        $attr['loading']       = 'eager';
        $attr['fetchpriority'] = 'high';
        $attr['decoding']      = 'async';
    }
    return $attr;
}, 10, 2);

On SIREH Cancún, a real estate site that sells on renders and video, the Home's server responded in about 0.7 s (TTFB) in the latest measurement. Renders are converted to WebP automatically on upload, the theme is a minimal one, and the virtual-tour video is served from Vimeo instead of the hosting account.

INP: third-party scripts are the usual suspect

INP fails when the main thread is busy at the moment someone taps. In WordPress that is usually chat widgets, sliders, trackers and plugins that run JavaScript on every page whether it is needed or not. The fix is subtraction: load each script only on the pages that use it, and defer the rest until the user interacts.

CLS: reserve the space

Layout shift comes from images without dimensions, fonts that swap late, banners injected above the content and entrance animations that move things after the first paint. Give every image width and height, and reserve the height of anything that loads later.

Case Study: what I measure across 23+ production sites

I operate more than 23 WordPress sites in production on AlmaLinux with WHM, Apache and PHP-FPM. For each one I track p75 field data on mobile with the script above, not a lab score.

What is already measured and published:

  • Conqr: CLS went from 0.94 to 0 against the original concept, and Lighthouse in production (median of 3 runs) gave CLS 0 and SEO 100 on all five pages measured. Mobile performance landed between 54 and 66, because the test server has no GPU and draws the site's 3D figure on the CPU. I publish that number too: a score that hides its context is not data.
  • SIREH Cancún: about 0.7 s of server response on the Home, with full renders and video.

A real error, mine: when page caching was switched on for Conqr, the staging site returned a 500 error for about 5 minutes. WP-CLI had run as root, the cache plugin rewrote its configuration with root as the owner, and PHP-FPM, which runs as the account user, could no longer read it. Restoring the owner and permissions fixed it. It happened on staging, not production, and it left a rule: WP-CLI always runs as the account user, never as root.

The error I see most in the industry: stacking a cache plugin, an "optimization" plugin and a CDN plugin on a server that was slow to begin with. They minify and combine the same files twice, fight over the cache, and nobody can tell which one broke the checkout. The site gets a better lab score for a week and the same field data.

What I would NOT do

I don't optimize for the Lighthouse number. It is a lab test on one machine. I report p75 field data, because that is how the thresholds are defined, and because a client's customers are not running Lighthouse.

I don't fix a slow server with more plugins. If the TTFB is high, every plugin is decorating a slow page. I start with PHP-FPM, OPcache and page caching at the server level, measure again, and only then touch the front end.

Next step

Is your WordPress site failing Core Web Vitals and nobody can say why? Send me the URL. I'll pull its field data, tell you whether the problem is the server, the theme or a plugin, and what I would fix first. Write to me. Get a quote on WhatsApp in 2 min

Samuel Torres Pichardo

Samuel Torres Pichardo
Software and cloud engineer in Mexico City, with about 3 years of professional experience.
About me · LinkedIn · GitHub · Contact