WP Manifestindependent plugin directory

LCP Priority Helper for Elementor

Reduces LCP render delay on Elementor sites by prioritizing the first image and preloading hero backgrounds and fonts—without changing content/SEO.

★ 0stars

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/tombrian/lcpphe/archive/refs/heads/main.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

Author: Thomas Kamau (kamau.dev) Plugin site: https://github.com/TomBrian/LCPPHE

Reduce Largest Contentful Paint (LCP) delays on Elementor-powered WordPress sites without changing content or SEO. This plugin prioritizes the first above-the-fold media and preloads the hero background image and optional hero fonts.

Features

  • First image on the page gets loading="eager" and fetchpriority="high" (without duplicating existing attributes).
  • Disables lazy-loading for the first img or iframe injected by core filters.
  • Detects Elementor hero background (first section/container with background_background = classic) and injects <link rel="preload" as="image" fetchpriority="high"> in <head>.
  • Responsive background support: prefers Mobile > Tablet > Desktop when enabled; optional fallback preload if different (cap 2 total).
  • Optional font preloads: add up to 5 local .woff2 URLs via Settings → LCP Helper.
  • Optional preconnect to fonts.gstatic.com (toggle off by default).
  • Front-end only; skips admin, feeds, REST, login, AJAX, CRON; does nothing on 404 or non-singular pages.

Requirements

  • WordPress 5.9+
  • PHP 7.4+

How it works

  1. Hooks wp_get_attachment_image_attributes to set loading=eager and fetchpriority=high for the first attachment image only.
  2. Hooks wp_lazy_loading_enabled to disable lazy-loading for the first img/iframe only.
  3. On singular views, reads the current post’s _elementor_data (JSON), DFS the node tree, and finds the first section/container with a classic background image. Resolves attachment IDs to URLs if present, and prints a single preload link (skips offsite URLs).
  4. Prints font preloads in <head> based on configured local .woff2 URLs (if any). Optionally prints a preconnect to https://fonts.gstatic.com.

Settings (Settings → LCP Helper)

Go to Settings → LCP Helper:

  • Preload mobile/tablet background intelligently (default ON)
  • Also preload one fallback (tablet/desktop) if different (default ON)
  • Affect iframes (default OFF)
  • Font .woff2 URLs to Preload: up to 5 local paths, e.g. /wp-content/uploads/fonts/hero-regular.woff2.
  • Enable preconnect to fonts.gstatic.com: toggle ON only if Google Fonts are used.

Known limitations

  • Only the first hero background from Elementor is preloaded. Complex templates with multiple hero sections will only preload the first found.
  • Only local .woff2 fonts are preloaded to avoid CORS and privacy issues.
  • The plugin does not alter page content or SEO; it only adjusts resource loading hints.

Must-Use (MU) plugin snippet (optional)

If you want to load this plugin as an MU plugin without activation, create wp-content/mu-plugins/lcp-priority-helper-loader.php with:

<?php
// MU loader for LCP Priority Helper for Elementor.
$plugin = WP_CONTENT_DIR . '/plugins/lcp-priority-helper/lcp-priority-helper.php';
if ( file_exists( $plugin ) ) {
    include_once $plugin;
}

Adjust the path if the plugin is placed elsewhere.