• Resolved abuzon

    (@abuzon)


    This is probably more of a “feature request” than a Support Request because I think I already know the answer…
    Defer JS breaks V3 reCAPTCHA and there’s no way to exclude it. In this instance, it’s reCaptcha for WooCommerce, checkout page. “Invalid site key or not loaded in api.js”

    I’m finding this to be a frequent issue with many of the defer and combine settings – there’s a small list of files SG Optimizer pulls to Exclude and nothing else can be excluded manually – rendering all these wonderful features useless because they break the site.
    Is there any plan to add/allow for manual exclusions? Or is there any plan to expand the list of possible file exclusions?
    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Stoyan Georgiev

    (@stoyangeorgiev)

    Hello there @abuzon,

    You can exclude script from being loaded asynchronous using the filter we’ve designed for that purpose. Here’s an example of the code:

    
    add_filter( 'sgo_js_async_exclude', 'js_async_exclude' );
    function js_async_exclude( $exclude_list ) {
        $exclude_list[] = 'script-handle';
        $exclude_list[] = 'script-handle-2';
    
        return $exclude_list;
    }
    

    Kind Regards,
    Stoyan

    Thread Starter abuzon

    (@abuzon)

    Well that’s great news! Thanks @stoyangeorgiev!
    Do you have any documentation on using this filter? Any additional information you can provide would be appreciated. I.e., assuming it goes in functions.php? Assuming “script-handle” would be the js file name(s), like recaptcha__en.js? This filter says async, but it’s used for defer? And is there a filter for excluding files from minification, or for CSS minify or combine?
    Thanks again!

    A guide to filters is pinned to the top of the SGO Support topics: https://www.ads-software.com/support/topic/how-to-use-sg-optimizers-filters-procedure/

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Defer JS breaks WooCommerce reCAPTCHA and can’t be excluded’ is closed to new replies.