tyler06_34 Posted January 15, 2021 Share Posted January 15, 2021 Hi, Very nice post ! Thank you for sharing. On 1/6/2021 at 3:11 AM, tomerg3 said: ReCaptcha * Google ReCaptcha We noticed a substantial slowdown in the time the front end page finishes loading (sometimes taking 5-7 seconds). We recommend restricting the ReCaptcha code to a specific page (like contact form) rather than enable it for all page loads (in case there's a newsletter signup form in the footer). I installed a ReCaptcha addon from Prestashop Addons and and I see that there is a javascript call (recaptcha__fr.js) on all of my product pages. Very annoying because I only want this on the contact form. Do you have the solution to solve the problem? I see something like that on recaptcha.php if ($this->context->controller instanceof ControllerBackwardModule || $this->context->controller instanceof ProductController || ($this->context->controller instanceof ContactController && Configuration::get('CAPTCHA_ENABLE_CONTACT')) || ($this->context->controller instanceof AuthController && Configuration::get('CAPTCHA_ENABLE_ACCOUNT')) || ($this->context->controller instanceof ParentOrderController && Configuration::get('CAPTCHA_ENABLE_ACCOUNT')) || ($this->context->controller instanceof OrderOpcController && Configuration::get('CAPTCHA_ENABLE_ACCOUNT')) || ($this->context->controller instanceof OrderController && Configuration::get('CAPTCHA_ENABLE_ACCOUNT')) || $this->context->controller instanceof StoresPagesStoreModuleFrontController) { if (method_exists($this->context->controller, 'registerJavascript')) { $this->context->controller->registerJavascript( 'remote-recaptcha', 'https://www.google.com/recaptcha/api.js?hl='.$this->context->language->language_code, array('server' => 'remote') ); } elseif (version_compare(_PS_VERSION_, '1.5.0', '>') && method_exists($this->context->controller, 'addJS')) { $this->context->controller->addJS('https://www.google.com/recaptcha/api.js?hl='.$this->context->language->language_code, false); } elseif (version_compare(_PS_VERSION_, '1.5.0', '>') && method_exists(Tools, 'addJS')) { Tools::addJS('https://www.google.com/recaptcha/api.js?hl='.$this->context->language->language_code, false); } else { return '<script src="https://www.google.com/recaptcha/api.js?hl='.$this->context->language->language_code.'" async defer></script>'; } } Thank you for your help. Link to comment Share on other sites More sharing options...
tomerg3 Posted January 19, 2021 Share Posted January 19, 2021 I started a new thread for this question, as it is not really related to the speed tips, but rather an issue with a module. I suggest you contact the module developer and ask them about this. You can also try to modify the code your posted so it only displays for ContactController and remove the other conditions. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now