Is it possible to load recaptcha script only in url with fragment identifier (#)?

Question

I have tried various snippets, like this:

<?php   
add_action( 'wp_print_scripts', 'load_captcha_script', 100 );
   function load_captcha_script() {
    if ( !is_page( '#register' ) ) {
        wp_deregister_script('google-recaptcha');
    }
   }

but it doesn’t work in #register section with hash, I also tried with if (window.location.hash == "#register")

But nothing, recaptcha doesn’t load when floating form appears, Is there a snippet that only loads the script when the section appears?

0
DrWho 2 years 2020-10-25T01:10:37-05:00 0 Answers 17 views 0

Leave an answer

Browse
Browse