Conversation
supportHello, anyone can tell me a way to defer the script of loading google recaptcha included in this plugin? <script src=” https://www.google.com/recaptcha/api.js?render=explicit&onload=cfsInitCaptcha&ver=1.6.5″></script> ; I see a bad performance on my web site loading speed with that script. I don’t want to use some plugin like Async Js. I want something that affect just this script. Thanks
Can anyone help me?
Hello, @leoidro Thank you for contacting us regarding your question! We have already made this fix. You can wait for release of this version or make fix in your plugin yourself. Replace frame.php file via FTP. Path: /classes/frame.php frame.php Code: public function add_defer_attribute($tag, $handle) { // add script handles to the array below switch ($handle) { case 'google.recaptcha': return str_replace(' src', ' defer="defer" src', $tag); break; case 'google.recaptcha.frontend': return str_replace(' src', ' defer="defer" src', $tag); break; } return $tag; } Best regards, Ole
Thank you for your answer. So I just have to add that code to the end of the frame.php file?
Just replace the file that we provided to you.
The file frame.php that you provided to me is exactly the same to the file that I already have, and doesn’t contain the function add_defer_attribute that you link above. How is it possible?
Please re-download file . This reply was modified 6 years, 8 months ago by supsystic .
I tried your solution but it’s doesn’t work. The problem of Google recaptcha that doesn’t defer remain. This is the report from Gtmetrix.com: 524.6KiB of JavaScript is parsed during initial page load. Defer parsing JavaScript to reduce blocking of page rendering. https://www.gstatic.com/recaptcha/api2/v1566858990656/recaptcha__en.js (215.7KiB) https://www.gstatic.com/recaptcha/api2/v1566858990656/recaptcha__en.js (215.7KiB)
Please contact us through our internal support . We will help you to solve the problem.
Can anyone help me?
Hello, @leoidro Thank you for contacting us regarding your question! We have already made this fix. You can wait for release of this version or make fix in your plugin yourself. Replace frame.php file via FTP. Path: /classes/frame.php frame.php Code: public function add_defer_attribute($tag, $handle) { // add script handles to the array below switch ($handle) { case 'google.recaptcha': return str_replace(' src', ' defer="defer" src', $tag); break; case 'google.recaptcha.frontend': return str_replace(' src', ' defer="defer" src', $tag); break; } return $tag; } Best regards, Ole
Thank you for your answer. So I just have to add that code to the end of the frame.php file?
Just replace the file that we provided to you.
The file frame.php that you provided to me is exactly the same to the file that I already have, and doesn’t contain the function add_defer_attribute that you link above. How is it possible?
Please re-download file . This reply was modified 6 years, 8 months ago by supsystic .
I tried your solution but it’s doesn’t work. The problem of Google recaptcha that doesn’t defer remain. This is the report from Gtmetrix.com: 524.6KiB of JavaScript is parsed during initial page load. Defer parsing JavaScript to reduce blocking of page rendering. https://www.gstatic.com/recaptcha/api2/v1566858990656/recaptcha__en.js (215.7KiB) https://www.gstatic.com/recaptcha/api2/v1566858990656/recaptcha__en.js (215.7KiB)
Please contact us through our internal support . We will help you to solve the problem.