(function() {
// Watch for Ezoic activating placeholders
const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
const target = mutation.target;
// When Ezoic starts adding content to a placeholder
if (target.id && target.id.startsWith(‘ezoic-pub-ad-placeholder-‘)) {
// Reserve space immediately when content starts loading
if (target.children.length > 0 && !target.dataset.sized) {
target.style.minHeight = ‘280px’;
target.dataset.sized = ‘true’;
// Once ad fully loads, lock to actual height and remove min-height
const adHeight = target.offsetHeight;
if (adHeight > 0) {
target.style.minHeight = adHeight + ‘px’;
}
}
}
});
});
// Start observing the whole document for placeholder changes
observer.observe(document.body, {
childList: true,
subtree: true,
attributes: true
});
})();