Page Speed Insights Remove unused JavaScript for Google Recaptcha
Asked Answered
P

1

6

I have a site that scores well on Google Page Speed Insights, but it shows a performance issue that says "Remove unused JavaScript" for this file:

https://www.gstatic.com/recaptcha/releases/2diXFiiA9NsPIBTU15LG6xPf/recaptcha__en.js

However, I have tried removing my Invisible Captcha plugin, and also adding this line of code to functions.php:

add_action('wp_print_scripts', function () {
    if ( is_home() ){
        wp_dequeue_script( 'google-recaptcha' );
        wp_dequeue_script( 'google-invisible-recaptcha' );
    }
});

But I still get the error. Is there anything I can do to remove this script from loading on my home page? My site is using the latest version of Wordpress.

Parquetry answered 11/6, 2020 at 21:46 Comment(1)
I'm also curious about this. I have seen similar performance issues.Foxtail
E
0

the below worked for me:

add_action( 'wp_enqueue_scripts', 'mytheme_deregister_scripts' );
function mytheme_deregister_scripts() {
  if( is_home() || is_front_page() ) :
    wp_deregister_script('google-invisible-recaptcha');
  endif;
}
Enscroll answered 19/4, 2021 at 7:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.