WP Manifestindependent plugin directory
manifest / performance / cf7-asset-optimizer

CF7 Asset Optimizer

Only loads Contact Form 7 scripts and styles on pages that contain a form. Performance optimization for CF7.

★ 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/renzojohnson/cf7-asset-optimizer/archive/refs/heads/main.zip

On Packagist as renzojohnson/cf7-asset-optimizer:

composer require renzojohnson/cf7-asset-optimizer
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.
CF7 Asset Optimizer Only loads Contact Form 7 scripts and styles on pages that actually contain a form. Zero configuration. Fixes Contact Form 7 #1278 — CF7 enqueues its JS, CSS, reCAPTCHA, Turnstile, and Stripe scripts on every single page, even pages with no form. This plugin detects whether the current page has a CF7 form and dequeues all CF7 assets when no form is present. Author: Renzo Johnson Requirements - PHP 8.4+ - WordPress 6.4+ - Contact Form 7 5.0+ Installation Via Composer Manual Download and upload to /wp-content/plugins/cf7-asset-optimizer/, then activate. As mu-plugin Copy cf7-asset-optimizer.php to /wp-content/mu-plugins/. How It Works The plugin hooks into CF7's own wpcf7loadjs and wpcf7loadcss filters to conditionally disable asset loading. On pages without a form, it also dequeues module scripts (reCAPTCHA, Turnstile, Stripe, SWV). Detection The plugin checks for CF7 forms in: - [contact-form-7] shortcode in post content - [contact-form] shortcode (legacy alias) - contact-form-7/contact-form-selector Gutenberg block - CF7 widgets in sidebar areas - CF7 shortcodes inside text widgets - CF7 blocks inside block widgets Assets Dequeued When no form