Trying to make iframe to lazyload

Viewed 6

Trying to make an iframe to lazyload, actually taken this as example of what should I do, but can not make it work. I'm doing this, because loading="lazy" doesn't really work with Google PageSpeedInsights, so i'm trying something new. All help greatly appreciated!

<section id="comments">
<div id="iframe"><iframe loading="lazy" style="width:100%;height:100%;border:1px solid #e6e6e6;border-radius:8px;box-sizing:border-box" src="about:blank" data-src="https://yandex.ru/maps-reviews-widget/17800148116?comments"></iframe><a href="https://yandex.ru/maps/org/dizayn_interyera_studiya_dizayna_mariny_balagayevoy/17800148116/" target="_blank" rel="nofollow" style="box-sizing:border-box;text-decoration:none;color:#b3b3b3;font-size:10px;font-family:YS Text,sans-serif;padding:0 20px;position:absolute;bottom:8px;width:100%;text-align:center;left:0;overflow:hidden;text-overflow:ellipsis;display:block;max-height:14px;white-space:nowrap;padding:0 16px;box-sizing:border-box">Дизайн интерьера. Студия дизайна Марины Балагаевой на карте Великого Новгорода — Яндекс Карты</a></div>
</section>

<script>
var $iframe=document.getElementById('iframe').find('iframe');
if ($iframe.data('src')){ // only do it once per iframe
    $iframe.prop('src', $iframe.data('src')).data('src', false);
}
</script>
0 Answers
Related