Load reCAPTCHA badge on required pages
By default Contact Form 7 loads reCAPTCHA on every single WordPress post or page. It shows the reCAPTCHA badge, and loads an external script that increases website loading time (not by much, but it still adds up).
- Go to your WordPress Admin Panel
- Navigate to Appearance > Theme File Editor > Theme Functions
- Add following code in your functions.php and Click Update File
function block_recaptcha_badge() {
if ( !is_page( array( 'contact' ) ) ) {
wp_dequeue_script( 'google-recaptcha' );
wp_deregister_script( 'google-recaptcha' );
add_filter( 'wpcf7_load_js', '__return_false' );
add_filter( 'wpcf7_load_css', '__return_false' );
}
}
add_action( 'wp_print_scripts', 'block_recaptcha_badge' );