Отложенная загрузка recaptcha для CF7

В functions.php отключаем подключение скриптов
function recaptcha_dscripts(){
	wp_dequeue_script('google-recaptcha');
	wp_dequeue_script( 'wpcf7-recaptcha' );
}
add_action( 'wp_enqueue_scripts', 'recaptcha_dscripts',99 );
И добавляем вот такую функцию для подключения каптчи в момент, когда курсов попадает в поле ввода. Не забыть изменить ключи сайта на свои.
	var enable_captcha = () => {

		  var captchaLoaded = false;
		  //Load reCAPTCHA script when CF7 form field is focused
		  $('.wpcf7-form input').on('focus', function () {
		// If we have loaded script once already, exit.
		   if (captchaLoaded) {
		    return;
		   }

		// Variable Intialization
		   console.log('reCAPTCHA script loading.');
		   var head = document.getElementsByTagName('head')[0];
		   var recaptchaScript = document.createElement('script');
		   var recaptchaScript2 = document.createElement('script');
		   var cf7script0 = document.createElement('script');
		   var cf7script = document.createElement('script');

		// Add the recaptcha site key here.
		   var recaptchaKey = '6LcowCwmAAAAAJI10Eg4NVakIZvRIyh_GxmJb0ix';

		// Dynamically add Recaptcha Script
		   recaptchaScript.type = 'text/javascript';
		   recaptchaScript.src = 'https://www.google.com/recaptcha/api.js?render=' + recaptchaKey + '&ver=3.0';

		   recaptchaScript2.type = 'text/javascript';
		   recaptchaScript2.src = '/wp-content/plugins/contact-form-7/modules/recaptcha/index.js?ver=5.4.1';

		// Dynamically add CF7 script
		   cf7script.type = 'text/javascript';
		   cf7script0.type = 'text/javascript';

		   cf7script0.text = 'var wpcf7_recaptcha = {"sitekey":"6LcowCwmAAAAAJI10Eg4NVakIZvRIyh_GxmJb0ix","actions":{"homepage":"homepage","contactform":"contactform"}};';

		   cf7script.text = "!function(t,e){var n={execute:function(e){t.execute(\'' + '6LcowCwmAAAAAJI10Eg4NVakIZvRIyh_GxmJb0ix' +'\',{action:e}).then(function(e){for(var t=document.getElementsByTagName(\'form\'),n=0;n<t.length;n++)for(var c=t[n].getElementsByTagName(\'input\'),a=0;a<c.length;a++){var o=c[a];if(\'_wpcf7_recaptcha_response\'===o.getAttribute(\'name\')){o.setAttribute(\'value\',e);break}}})},executeOnHomepage:function(){n.execute(e.homepage)},executeOnContactform:function(){n.execute(e.contactform)}};t.ready(n.executeOnHomepage),document.addEventListener(\'change\',n.executeOnContactform,!1),document.addEventListener(\'wpcf7submit\',n.executeOnHomepage,!1)}(grecaptcha,{homepage:\'homepage\',contactform:\'contactform\'});";

		   head.appendChild(cf7script0);
		   head.appendChild(recaptchaScript);

		   setTimeout(function () {
		    head.appendChild(cf7script);
		    head.appendChild(recaptchaScript2);
		    console.log('reCAPTCHA script loaded');
		   }, 200);

		   captchaLoaded = true;
		  });
	}