Sakamoto Ryōma
Verified User
- Joined
- Jun 4, 2011
- Messages
- 69
Hello everyone,
There are more than 5 million WordPress websites that use the Contact Form 7 plugin. The main speed issue with this plugin is that it adds its required CSS and JavaScript files to all pages on the site. They do this because if you have a newsletter subscription form in your site footer, the Contact Form 7 files need to be loaded on all pages. But what if you don't have such forms? It can slow down your website.
There's a quick fix for this by adding some code to the functions.php file, as shown in the example below:
You can read further about alternative code options to use in the functions.php file on this blog.
Alternatively, we've created a tiny plugin called Rufo (Remove Unneeded Files of Contact Form 7) for those who don't want to bother with code.
Have a great weekend!
There are more than 5 million WordPress websites that use the Contact Form 7 plugin. The main speed issue with this plugin is that it adds its required CSS and JavaScript files to all pages on the site. They do this because if you have a newsletter subscription form in your site footer, the Contact Form 7 files need to be loaded on all pages. But what if you don't have such forms? It can slow down your website.
There's a quick fix for this by adding some code to the functions.php file, as shown in the example below:
Code:
if ( !is_singular() && !in_array(get_the_ID(), [65,99]) ) {
add_filter( 'wpcf7_load_js', '__return_false' );
add_filter( 'wpcf7_load_css', '__return_false' );
}
You can read further about alternative code options to use in the functions.php file on this blog.
Alternatively, we've created a tiny plugin called Rufo (Remove Unneeded Files of Contact Form 7) for those who don't want to bother with code.
Have a great weekend!