• Resolved honorcoding

    (@honorcoding)


    Google Recaptcha code adds extra javascript bloat and slows down the site. Is there a way to disable the recaptcha javascript code from being loaded on all pages except a select few (e.g. registration, contact, etc). For example, is there a hook or some php code I can add that disables this plugin?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @honorcoding

    Yes, you can remove JS and Style added by this plugin from unwanted pages. You can use the following lines of code to do so.

    function agr_dequeue_script() {
    
    	if( !is_page( array( 'registration', 'contact-us' ) ) ){
    		
    		//remove scripts
    		wp_dequeue_script( 'advanced-google-recaptcha-custom' );
    		wp_dequeue_script( 'advanced-google-recaptcha-api' );
    
    		//remove style
    		wp_dequeue_style( 'advanced-google-recaptcha-style' );
    	}
    
    }
    
    add_action( 'wp_enqueue_scripts', 'agr_dequeue_script', 100 );

    You can add this line of codes to the functions.php of your theme. In the code above, you can change the slug of the pages as per your need.

    Please let us know if you need further help.

    Kind Regards,
    Manesh Timilsina
    WP Concern

    Hello! Added this code. Now in the comments there is an error “ERROR: Google reCAPTCHA verification failed.”

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Is there a way to disable Google Recaptcha on select pages?’ is closed to new replies.