From 8e5f3996ddd6b6dbc82088838d49639176632dab Mon Sep 17 00:00:00 2001 From: Kostadin Bashev Date: Sat, 24 Jan 2026 17:39:54 +0200 Subject: [PATCH 1/2] Load recaptcha related files on focus of the form fields. --- .../view/frontend/web/js/reCaptcha.js | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js b/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js index 4fdca404..24a21678 100644 --- a/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js +++ b/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js @@ -28,7 +28,16 @@ define( */ initialize: function () { this._super(); - this._loadApi(); + + this.attachFocusEvent(); + }, + + attachFocusEvent: function () { + const self = this, $parentForm = $('#' + this.getReCaptchaId() + '-container').parents('form'); + + $parentForm.one('focus', 'input, select, textarea', function () { + self._loadApi(); + }); }, /** @@ -59,9 +68,7 @@ define( * @returns {Boolean} */ getIsInvisibleRecaptcha: function () { - if (this.settings === - - void 0) { + if (this.settings === void 0) { return false; } @@ -95,9 +102,7 @@ define( widgetId, parameters; - if (this.captchaInitialized || this.settings === - - void 0) { + if (this.captchaInitialized || this.settings === void 0) { return; } @@ -226,3 +231,4 @@ define( } }); }); + \ No newline at end of file From 35fc6b91bc95e102167451f387cfb3be3e1f5515 Mon Sep 17 00:00:00 2001 From: Kostadin Bashev Date: Fri, 27 Feb 2026 10:10:46 +0200 Subject: [PATCH 2/2] Remove unnecessary newline in reCaptcha.js --- ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js | 1 - 1 file changed, 1 deletion(-) diff --git a/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js b/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js index 24a21678..dbca57cd 100644 --- a/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js +++ b/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js @@ -231,4 +231,3 @@ define( } }); }); - \ No newline at end of file