) are rare * in real post content; we leave those alone with a pre-pass that * stubs out script / style / pre blocks before rewriting. * * @package XSpeed */ declare(strict_types=1); namespace XSpeed; defined( 'ABSPATH' ) || exit; final class Lazy_Loader { /** * In-process counter for above-the-fold skipping. Reset by * process_html on every call so a fresh post starts at 0. * * @var int */ private static $image_counter = 0; /** * Settings cache (one read per request). * * @var array|null */ private static $opts = null; /** * Main entry point: take rendered HTML, return rewritten HTML. * Pure function aside from the static counters. */ public static function process_html( string $html ): string { if ( '' === $html ) { return $html; } $opts = self::opts(); // Reset per-call so each filter invocation starts a fresh // "first N images go eager" budget. The_content fires once // per post in the loop; new post → reset counter. self::$image_counter = 0; // Stub out