| Server IP : 172.173.179.141 / Your IP : 216.73.216.196 Web Server : Apache System : Linux mail.lomejor.cr 6.8.0-1059-azure #65~22.04.1-Ubuntu SMP Thu May 28 16:59:19 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.2.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/bamagocr/wp-content/plugins/embed-optimizer/ |
Upload File : |
/**
* Lazy load embeds
*
* When an embed block is lazy loaded, the script tag is replaced with a script tag that has the original attributes
*/
const lazyEmbedsScripts = document.querySelectorAll(
'script[type="application/vnd.embed-optimizer.javascript"]'
);
const lazyEmbedScriptsByParents = new Map();
const lazyEmbedObserver = new IntersectionObserver(
( entries ) => {
for ( const entry of entries ) {
if ( entry.isIntersecting ) {
const lazyEmbedParent = entry.target;
const lazyEmbedScript =
/** @type {HTMLScriptElement} */ lazyEmbedScriptsByParents.get(
lazyEmbedParent
);
const embedScript =
/** @type {HTMLScriptElement} */ document.createElement(
'script'
);
for ( const attr of lazyEmbedScript.attributes ) {
if ( attr.nodeName === 'type' ) {
// Omit type=application/vnd.embed-optimizer.javascript type.
continue;
}
embedScript.setAttribute(
attr.nodeName === 'data-original-type'
? 'type'
: attr.nodeName,
attr.nodeValue
);
}
lazyEmbedScript.replaceWith( embedScript );
lazyEmbedObserver.unobserve( lazyEmbedParent );
}
}
},
{
rootMargin: '100% 0% 100% 0%',
threshold: 0,
}
);
for ( const lazyEmbedScript of lazyEmbedsScripts ) {
const lazyEmbedParent =
/** @type {HTMLElement} */ lazyEmbedScript.parentNode;
if ( lazyEmbedParent instanceof HTMLElement ) {
lazyEmbedScriptsByParents.set( lazyEmbedParent, lazyEmbedScript );
lazyEmbedObserver.observe( lazyEmbedParent );
}
}