Make contact form 7 faster with a simple trick

Last edited:
November 5, 2023
Reading time:
3 mins

/

Blog

/

Speed

/

Make contact form 7 faste...

đź’ˇWe may earn a commision if you subscribe to a service from a link on this page.

Contact Form 7 (CF7) is one of the most popular contact form plugins for WordPress, known for its simplicity and ease of use. However, it has often received criticism for its user interface, which might not be as intuitive as some of its competitors. While this user interface aspect has led to lower ratings in comparison to other famous plugins, it’s important to note that CF7 remains a robust choice, especially for those with a knack for a bit of coding.

In fact, its lightweight and fast nature make it a preferred option for many website owners. But, even in its swiftness, there are situations where it could use a boost in performance. In this article, we’ll delve into a simple trick to make Contact Form 7 even faster by addressing a specific issue that might be slowing down your site.

Speed concerns about Contact Form 7

One of the key benefits of using Contact Form 7 is its lightweight design. Probably it’s the most lightweight plugin for contact forms, making it the excellent choice for those who don’t care about user interface in settings and prefer fast loading times. However, there’s a specific scenario that can hinder its performance. When a visitor arrives on your site and interacts with a Contact Form 7 form, CF7 attempts to preload and populate the form with any previously entered data.

This feature is a handy way to enhance the user experience, but it comes at a cost – the loading of resources from “/wp-json/contact-form-7/v1/contact-forms/1555/feedback/schema.” This process, which occurs to build preloads as placeholders, can slow down your site, impacting its overall speed and user experience.

Discover the issue through GTMetrix

To verify this, you can visit GTmetrix, a popular website performance analysis tool. After analyzing your site, navigate to the Waterfall tab, where you can examine the sequence of requests made during the page load.

Look for the request titled “schema,” which often takes approximately 350ms to complete. This delay may not seem like much, but in the world of web performance, every millisecond counts.

Making contact form 7 faster

The good news is that there’s a straightforward way to address this issue and make Contact Form 7 faster. By adding a small code snippet to your website’s functions.php file, you can prevent CF7 from making this specific request, thus speeding up your site’s load time.

Here’s how you can do it:

  1. Go to your WordPress dashboard and navigate to the “Appearance” section.
  2. Select “Theme Editor” to access the theme files.
  3. On the right-hand side, locate and click on “Theme Functions” (functions.php) to open the file.
  4. Inside the file, you’ll need to add a small piece of script to stop the CF7 cache. The code block should look something like this:
<?php // do not copy this line 

//stop Contact Form 7 caching for speed gains 
function stop_cf7cache_wpr(){ 
?> 
<script>
     if ((typeof wpcf7 !== 'undefined') && (wpcf7)) {
        wpcf7.cached=0;
     }
    </script>
  <?php
}

add_action('wp_footer', 'stop_cf7cache_wpr', 999);
  1. Save the changes to your functions.php file.

Once you’ve made this adjustment, your Contact Form 7 plugin will no longer load the schema request when users interact with your forms, resulting in a faster and more responsive user experience.

Clear cache and re-test

After implementing this simple trick, it’s a good practice to recheck your site’s performance on GTmetrix. You should notice a notable improvement in the loading times, with the “schema” request no longer causing delays.

Make your WordPress faster when using Contact Form 7

In conclusion, Contact Form 7 is a valuable tool for adding contact forms to your WordPress site, and its lightweight nature makes it an attractive choice. However, the unnecessary schema request can sometimes hinder your site’s performance. By following the steps outlined in this article and making a simple adjustment to your functions.php file, you can enjoy the benefits of CF7 without compromising on site speed. Your visitors will thank you for the improved user experience, and your website’s overall performance will receive a welcomed boost.

Leave a Reply

Your email address will not be published. Required fields are marked *