D
D
denism3002019-03-18 18:48:32
JavaScript
denism300, 2019-03-18 18:48:32

How to speed up page loading with multiple reCaptchas?

There are 15 popup forms on the page.
I attached an invisible recaptcha to them like this:

<script type="text/javascript">
    var onloadCallback = function() {
        $(".g-recaptcha").each(function() {
            var el = $(this);
            grecaptcha.render($(el).attr("id"), {
                "sitekey" : SITE_KEY,
                "callback" : function(token) {
                    $(el).parent().find(".g-recaptcha-response").val(token);
                    $(el).parent().submit();
                }
            });
        });
    };
</script>

<form>
    <input type="text" name="example"/>
    <button id="captcha1" class="g-recaptcha">submit form 1</button>
</form>

<form>
    <input type="text" name="example"/>
    <button id="captcha2" class="g-recaptcha">submit form 2</button>
</form>

<script src='https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit' async defer></script>

I took the idea of ​​​​how to implement several recaptchas here
, everything is ok, everything works, but the page loads about 10 seconds somewhere. how can i speed up?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Chernyavsky, 2019-03-18
@cherniasvky94

Alternatively, render the desired captcha only after opening the popup

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question