Skip to content

perf: preconnect + preload Slise embed so ad banners render as the pa…#686

Merged
liangping merged 1 commit into
ping-pub:masterfrom
devmildfire:perf/slise-ad-preconnect-eager-load
Jul 8, 2026
Merged

perf: preconnect + preload Slise embed so ad banners render as the pa…#686
liangping merged 1 commit into
ping-pub:masterfrom
devmildfire:perf/slise-ad-preconnect-eager-load

Conversation

@devmildfire

Copy link
Copy Markdown
Contributor

perf: preconnect + preload Slise embed so ad banners render as the page loads

Problem

The Slise ad banner stays blank for roughly a second after the page loads. The
embed script is only injected inside AdBanner's onMounted — after the app
bundle downloads, parses, and mounts the ad component — and it's requested over
a cold connection with no resource hints, so nothing about the ad load overlaps
the app boot.

Changes

index.htmlpreconnect/dns-prefetch the Slise origin and preload
embed.js, so the ~21 KB script downloads in parallel with the app bundle
instead of ~1 s later. embed.js is already allow-listed in the existing CSP,
so no CSP change is needed, and the script still only executes when an
AdBanner mounts — the preload just makes the bytes ready in advance.

AdBanner.vue — fill the slot on the script's load event instead of a
one-shot typeof window.adsbyslisesync === 'function' check. On the first
banner that function isn't defined yet (the async script is still loading), so
the previous code silently skipped the sync and the first ad only filled once
Slise's script finished and ran its own auto-sync. Waiting for load fills the
first banner the moment the script is ready.

Result

Measured on a local build: embed.js's request start moves from ~1013 ms to
~14 ms after navigation (now fetched by the preload), so the banner creative
can paint about a second sooner. yarn build (type-check + build) passes; the
diff is two files with no dependency or API changes.

…ge loads

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@liangping liangping merged commit c3154ef into ping-pub:master Jul 8, 2026
1 check passed
@liangping

Copy link
Copy Markdown
Member

@devmildfire Thanks for PR, it's better now, but there still a delayed refresh during page switching. you can take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants