# blockenberg/2.0.11/blocks/embed/frontend.js

Blockenberg — 600+ Advanced Gutenberg Blocks &amp; AI Agent for WordPress Block Editor, version 2.0.11. 43 lines.

- Page: https://pluginprobe.com/plugins/blockenberg/2.0.11/code/blocks/embed/frontend.js
- Raw: https://pluginprobe.com/plugins/blockenberg/2.0.11/raw/blocks/embed/frontend.js
- Modified: 2026-07-22T02:13:48+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/blockenberg/2.0.11/code/blocks/embed/frontend.js#L10-L20`.

```javascript
(function () {
    'use strict';

    // Embed Block — lazy-load iframes on scroll for performance
    function initEmbeds() {
        var iframes = document.querySelectorAll('.bkbg-embed-iframe[loading="lazy"]');
        if (!iframes.length) return;

        // Modern browsers handle loading="lazy" natively on iframes
        // This is a fallback for older browsers
        if ('loading' in HTMLIFrameElement.prototype) return;

        if (!('IntersectionObserver' in window)) return;

        var obs = new IntersectionObserver(function (entries) {
            entries.forEach(function (entry) {
                if (!entry.isIntersecting) return;
                var iframe = entry.target;
                var dataSrc = iframe.getAttribute('data-src');
                if (dataSrc) {
                    iframe.src = dataSrc;
                    iframe.removeAttribute('data-src');
                }
                obs.unobserve(iframe);
            });
        }, { rootMargin: '200px 0px' });

        iframes.forEach(function (iframe) {
            if (iframe.src && !iframe.getAttribute('data-src')) {
                iframe.setAttribute('data-src', iframe.src);
                iframe.removeAttribute('src');
            }
            obs.observe(iframe);
        });
    }

    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', initEmbeds);
    } else {
        initEmbeds();
    }
}());

```
