Welcome to WebmasterWorld Guest from 54.196.135.90

Forum Moderators: open

GCaptcha and settings for API

     
1:32 pm on Dec 19, 2017 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:Oct 25, 2006
posts: 1057
votes: 1


I like to know what is the best to use when implementing gCaptcha and API:
<script src='https://www.google.com/recaptcha/api.js?render=onload&amp;hl=en'></script>
or
<script src='https://www.google.com/recaptcha/api.js?hl=en&onload=MYscript&render=explicit" async defer'></script>

render=explicit and async defer or without?
3:16 pm on Jan 3, 2018 (gmt 0)

Administrator from US 

WebmasterWorld Administrator brett_tabke is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Sept 21, 1999
posts: 38131
votes: 47


defer. It won't slow down other loads that way. You want the Captcha to be one of the later things loaded.
3:21 pm on Jan 3, 2018 (gmt 0)

New User from CA 

joined:Mar 2, 2017
posts:30
votes: 2


Scripts loaded with ASYNC are parsed and executed immediately when the resource is done downloading. Whereas DEFER scripts donít execute until the HTML document is done being parsed (AKA, DOM Interactive or performance.timing.domInteractive).

Comparing the ASYNC and DEFER waterfalls, we see that using DEFER makes DOM Interactive fire sooner and allows rendering to proceed more quickly.

HOWEVER:

Even though ASYNC and DEFER donít block the HTML parser, they can block rendering. This happens when theyíre parsed and executed before rendering is complete and take over the browser main thread. Thereís nothing in the spec that says they have to wait until rendering is complete.

Source: [calendar.perfplanet.com...]
3:11 pm on Jan 11, 2018 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:Oct 25, 2006
posts: 1057
votes: 1


I have set Multiform Recaptcha. How to validate Google variable as positive that content can not be posted?

<!DOCTYPE HTML>

<html>

<head>
<title>gCaptcha and Multiforms design</title>
</head>

<body>
<form id="mycontactform1" method="post">

<script>
function IsRecapchaValid()
{
var res = grecaptcha.getResponse(form);
if (res == "" || res == undefined || res.length == 0)
{
return false;
}
return true;
}
var recaptcha1;
var recaptcha2;
var myCallBack = function() {
recaptcha1 = grecaptcha.render('recaptcha1',
{
'sitekey': 'XXX',
'theme': 'light'
}
);

recaptcha2 = grecaptcha.render('recaptcha2',
{
'sitekey': 'XXX',
'theme': 'dark'
}
);
};
</script>
<script src="https://www.google.com/recaptcha/api.js?hl=en&onload=myCallback&render=explicit" async defer></script>

<input type="submit" name="formsubmit1" data-callback="captchaSubmit" value="Send" class="" />

</form>
</body>

</html>

Can be improved this code as there are two captcha designs and need to pass variables into PHP variable like
$smarty->assign("gcaptcha", $gcatcha);

how to receive POST value in this case?
Need help
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members