Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- Warm up the Slise ad origin and start fetching the embed script in
parallel with the app bundle, so banners can render as the page loads
instead of after the ad component mounts. -->
<link rel="preconnect" href="https://v1.slise.xyz" crossorigin />
<link rel="dns-prefetch" href="https://v1.slise.xyz" />
<link rel="preload" href="https://v1.slise.xyz/scripts/embed.js" as="script" />
<title>Ping Dashboard - Cosmos Blockchain Explorer And Web Wallet</title>
<meta
name="description"
Expand Down
32 changes: 20 additions & 12 deletions src/components/ad/AdBanner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ declare global {
}
}

const SLISE_EMBED_SRC = 'https://v1.slise.xyz/scripts/embed.js';

const props = defineProps({
slot: {
type: String,
Expand Down Expand Up @@ -81,22 +83,28 @@ onMounted(() => {
observer.observe(containerRef.value);
}

// Load script only once
if (!document.querySelector('script[src="https://v1.slise.xyz/scripts/embed.js"]')) {
// Queue this slot for Slise.
window.adsbyslise = window.adsbyslise || [];
window.adsbyslise.push({ slot: props.slot });

// Fill the slot as soon as Slise's embed script is ready. Waiting for the
// script's `load` event (instead of a one-shot check) means the very first
// banner fills the moment the script arrives, rather than only on Slise's
// internal 1s location poll.
const sync = () => window.adsbyslisesync?.();
const existing = document.querySelector(`script[src="${SLISE_EMBED_SRC}"]`);

if (window.adsbyslisesync) {
sync();
} else if (existing) {
existing.addEventListener('load', sync, { once: true });
} else {
const script = document.createElement('script');
script.src = 'https://v1.slise.xyz/scripts/embed.js';
script.src = SLISE_EMBED_SRC;
script.async = true;
script.addEventListener('load', sync, { once: true });
document.head.appendChild(script);
}

// Initialize ad queue
window.adsbyslise = window.adsbyslise || [];
window.adsbyslise.push({ slot: props.slot });

// Sync if available
if (typeof window.adsbyslisesync === 'function') {
window.adsbyslisesync();
}
});

onBeforeUnmount(() => {
Expand Down
Loading