Skip to content

Instantly share code, notes, and snippets.

@aktaumag
Created September 30, 2020 23:52
Show Gist options
  • Save aktaumag/384a65e7e49045dc28cd4b3ee659d3a7 to your computer and use it in GitHub Desktop.
Save aktaumag/384a65e7e49045dc28cd4b3ee659d3a7 to your computer and use it in GitHub Desktop.
iframe без тормозов
Добавление на страницу iframe, которое не тормозит загрузку сайта
@aktaumag
Copy link
Author

При вышеописанной технологии, поисковые системы не видят видео на странице.

Если видео в пределах первого экрана, то используем вышеописанную технологию с применением разметки Schema.org

content-visibility: auto;

Работает только для видео за пределами первого экрана.

<style>
    .wsytcontainer {
        container-type: inline-size;
        container-name:youtubei;
        width:100%;
    }
    .wsytblock {
        /*width: clamp(320px, 100cqw, 520px);*/
        /*height: clamp(180px, 56.25cqw, 293px);*/
        /*margin: 0 auto;*/
        width: 100cqw;
        height: 56.25cqw;
        contain: layout;
        content-visibility: auto;
        contain-intrinsic-width: 100cqw;
        contain-intrinsic-height: 56.25cqw;
    }
    .wsytiframe {
        border: none;
        width: 100%;
        height: 100%;
    }
</style>
<div class="wsytcontainer">
    <div class="wsytblock">
        <iframe class="wsytiframe"  loading="lazy" src="...
    </div>
</div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment