CF7 Loading On All Pages – reCaptcha v3 – Fix
-
I care about page speed and site speed since it is my business to care.
When I learned that CF7, using Google reCaptcha v3, has to load on all pages, that concerned me because on a page speed test it listed CF7 as one of the scripts that was slowing the site down.
I have seen this kind of stuff before, website software written to the convenience of people causing performance problems. Even in Desktop OS’s, software has been and still is designed to load into the background and really slows the computer down.
In saying this, I came across a fix to stop CF7 from loading on all pages, while still filtering spam out and not interfering with good messages being sent through.
Disclaimer: This fix may not work for your site, because, as with any PHP coding, it can conflict with what you already have on your site. There is no warranty or guarantee with this fix. Test this fix to see if it works for you.
Load CF7 on Selected Pages
Using a child theme is best because when a theme is updated, it won’t erase this PHP modification.1. Refer to these websites to see the code used. The first is a YouTube instruction, the second is a webpage.
Both reference sites explain how to load CF7 only to a single contact page. The second link (webpage) includes the PHP code if you have a list of pages to include via the array syntax.
YouTube Reference
TechJourney Reference
https://techjourney.net/load-contact-form-7-cf7-js-css-conditionally-only-on-selected-pages/2. Insert the PHP code near the bottom of the functions.php file, just before the PHP ending
?>
tag. If there is no PHP ending tag, then at the bottom.Note: all PHP code must be inserted between the open and close PHP tags,
<?php
(and)?>
. So be mindful of where these tags are and if any PHP coding is closed. Sometimes, in PHP files you may see several sets of opening and closing tags, and many PHP files have no closing tags, but all have the opening tag.
- The topic ‘CF7 Loading On All Pages – reCaptcha v3 – Fix’ is closed to new replies.