A small guide that changes view without reloading the page.
The wrapper loads once in the <head>, the same way as on every site.
<script async src="https://hbw-cdn.hbwrapper.com/hbw.siteC.hbwrapper.com.js"></script>
Before the view changes, collect the slot elements the outgoing route owns.
var oldAds = [].slice.call(
view.querySelectorAll('[data-aaad="true"]')
);
Destroy those slots, write the new markup, then process what the new route brought with it — in that order.
window.hbw = window.hbw || { cmd: [] };
window.hbw.cmd.push(function () {
if (oldAds.length) {
window.hbw.destroy(oldAds);
}
view.innerHTML = html;
window.hbw.processAdsOnPage();
});
destroy() removes the elements as well. Pass false as the second argument to tear down the slots and keep the containers, which is what you want when your framework owns those nodes.
The first render runs the same path. There is nothing to destroy yet, so that step is skipped and the rest is identical.
Auction console: add ?hbwConsole to this URL.