• Resolved mrgvd

    (@mrgvd)


    Приветствую. Подскажите, а есть ли вариант сделать отложенную загрузку? А то гугл прямо очень ругается на обращение к яндексу. На целых 5 секунд.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author stasionok

    (@stasionok)

    Так там и так стоит defer и dns-prefetch. Сегодня яндекс чтото глюкавит сильно, Паспорт их вообще почти лежит. Может поэтому…

    Thread Starter mrgvd

    (@mrgvd)

    Всё-таки гугл очень ругается на эту историю. Подскажите, что я делаю не правильно? Хочу сначала удалить скрипт, а потом заново его загрузить. Но при загрузке получаю проверку обычную, не невидимую. Вот такой сейчас код:

    function remove_yandex_captcha_script($tag, $handle) {
    if ($handle === ‘cfyc-captcha’) {
    return ”; // Убирает тег <script> из кода
    }
    return $tag;
    }
    add_filter(‘script_loader_tag’, ‘remove_yandex_captcha_script’, 10, 2);

    function load_yandex_captcha_before_popup() {
    ?>
    <script>
    function loadYandexCaptcha() {
    if (!document.getElementById("cfyc-captcha-js")) {
    let script = document.createElement("script");
    script.src = "https://smartcaptcha.yandexcloud.net/captcha.js?render=onload&onload=cfycOnloadFunction";
    script.defer = true;
    script.id = "cfyc-captcha-js";
    script.onload = function() {
    if (typeof cfycOnloadFunction === "function") {
    cfycOnloadFunction();
    }
    };
    document.body.appendChild(script);
    } else {
    if (typeof cfycOnloadFunction === "function") {
    cfycOnloadFunction();
    }
    }
    }
    loadYandexCaptcha();
    setTimeout(function() {
    let form = document.querySelector(".popup-buy form");
    if (form) {
    let event = new Event("cfycCaptchaReadyEvent");
    document.dispatchEvent(event);
    }
    }, 500);
    </script>
    <?php
    }
    add_action('wp_footer', 'load_yandex_captcha_before_popup', 20);

    Plugin Author stasionok

    (@stasionok)

    Может поменять приоритет у add_action ?

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.