Slots Added After the Page Loads
The script finds the slots on the page when it starts, and then keeps watching the page. Slots added later, for example by infinite scrolling, content loaded with AJAX, or JCH Optimize's Reduce DOM, are picked up automatically as soon as they are inserted.
If your script inserts slots in a way the page watcher can't see, or you want to be certain, ask CLS Ad Slot to look again, either directly or with an event:
// Look for slots inside a container (or the whole page, without an argument)
window.ClsAdSlot?.scan(container);
// Or, without depending on the script having loaded yet
document.dispatchEvent(new CustomEvent('cls-ad-slot:scan', {detail: {root: container}}));
Both are safe to call as often as you like; a slot is set up only once. window.ClsAdSlot
exists once the script has started. An event sent before then isn't needed, because the script looks
through the whole page when it starts.
The slots must come from CLS Ad Slot modules rendered by Joomla, and the page they are added to must already have CLS Ad Slot's script, which it does when it was built with at least one slot.
With lazy loading off, each slot is followed by a small script that asks AdSense for its ad. Scripts in
HTML inserted with innerHTML don't run, so CLS Ad Slot asks for the ad itself when it
finds a slot whose script didn't run. The script marks its slot with data-ad-pushed, so
an ad is never requested twice.
On This Page