-
-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
Loading the recaptcha library impacts the google pagespeed. This can be resolved by loading it deferred like this:
<script src="https://www.google.com/recaptcha/api.js?render=[[+site_key]]&hl=[[++cultureKey]]&onload=onloadCallback&render=explicit" defer></script>
<input type="hidden" name="[[+token_key]]">
<input type="hidden" name="[[+action_key]]" value="[[+form_id]]">
<script>
function onloadCallback() {
grecaptcha.ready(function() {
grecaptcha.execute('[[+site_key]]', {action: '[[+form_id]]'}).then(function(token) {
document.querySelector('[name="[[+token_key]]"]').value = token;
});
});
}
</script>
Note the defer attribute on the script element and the onloadCallback function.
I think it would not be a problem to load it deferred in the default chunk.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels