Publisher Article Page Prebid.js v11 View: article Banner · Native · Video InView + Refresh /article/my-test-story

Slot 1 · Banner · Top Leaderboard · loads immediately

How the Wrapper Works: InView, Refresh & CSS Injection

One script tag. Everything else is in the wrapper.

The publisher adds <script async src="wrapper.js"></script> and places ad <div> elements wherever ads should appear. The wrapper resolves the current URL to a view, reads the slot config for that view, and manages the full ad lifecycle.

Wrapper div injection

Before requesting any bids, the wrapper inserts a .hb-slot-wrap div inside each publisher div. This gives a stable CSS target that survives GPT refreshes. The publisher div remains untouched. Global and per-slot CSS for both the wrapper div and the GPT iframe is declared in wrapper.js and applied automatically — including via a MutationObserver that catches the iframe the moment GPT renders it.

InView loading

Slots below the fold use IntersectionObserver to delay the bid request and GPT slot definition until the slot approaches the viewport. The rootMargin (default 200px) controls how early the load triggers. The top slot on this page has inView: false so it loads immediately. The MRect and video slots below use the network defaults.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip.

Slot 2 · Banner + Native · MRect · lazy (100px margin)

Refresh engine

Each slot has its own refresh config: interval, maxRefreshes, and minTimeInView. A second IntersectionObserver (threshold 50%) tracks whether the slot is actually visible. If the user has scrolled past the slot the refresh timer skips that cycle — no wasted impressions.

Setting refresh: false on a slot disables refresh entirely for that slot (useful for native units). Setting NETWORK.refresh.enabled: false disables it globally.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Slot 3 · Banner + Outstream Video · lazy (200px margin) · no mobile