1

in this site: https://kunstkeramikk.no/

Page Speed Insights says: Remove unused JavaScript for Google Recaptcha

have tried to use the solution proposed in this post but it does not work for me

Page Speed Insights Remove unused JavaScript for Google Recaptcha

 `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;
}`   
    
    
How can I solved this?
thank you

1 Answers1

1

You need to use the id of the script you want to de-register. I don't see an script tag with the id="google-invisible-recaptcha" in your source code. I see an id of 'et-recaptcha-v3-js'.

So change wp_deregister_script('google-invisible-recaptcha'); to wp_deregister_script('et-recaptcha-v3');

// Updated code

add_action( 'wp_enqueue_scripts', 'mytheme_deregister_scripts', 999 );
function mytheme_deregister_scripts() {
  if( is_home() || is_front_page() ) :
    wp_deregister_script('et-recaptcha-v3');
  endif;
}

I also added a high priority of 999.

harceo
  • 98
  • 8