Skip to content

Stop the unstyled flash looking like injected ads - #477

Merged
ralyodio merged 1 commit into
masterfrom
ads-fouc-placeholder
Nov 30, 2026
Merged

ralyodio merged 1 commit into
masterfrom
ads-fouc-placeholder

Conversation

@ralyodio

Copy link
Copy Markdown
Contributor

During a slow stylesheet load, /ads (and every marketing page) flashed a full-viewport logo plus raw markup that read like an injected ad.

  • Logo: pinned to 181x64 with an inline height in both headers (marketing had no size at all; app had 320x64, wrong aspect for the 489x173 viewBox).
  • ad.js placeholder: each data-cp-ad slot now paints a faint, theme-aware skeleton straight away, an inline SVG built in the tag (zero requests), sized to the format so the slot is reserved and nothing jumps. Swapped for the iframe on fill, removed on a no-fill, and skipped when the publisher put their own fallback markup in the container.

Checked: tsc clean, vitest 3185 passed; the snippet exercised in headless Chromium with stubbed fetch (placeholder 300x250 / 728x90 / 320x50 while loading, iframe after fill, collapses on no-fill, fallback untouched).

🤖 Generated with Claude Code

Two things painted badly in the gap before the stylesheet lands:

- The header logo had no intrinsic size (marketing) or the wrong aspect
  (app, 320x64 for a 489x173 viewBox), so it rendered at full viewport
  width. Pin it to 181x64 with an inline height.
- ad.js left each slot empty until /api/ads/serve answered, so the page
  jumped when the creative landed. It now paints a faint, theme-aware
  skeleton built as an inline SVG (no request) at the format's size,
  swapped for the iframe on fill and removed on a no-fill. A slot with
  the publisher's own fallback markup is left alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

ThreatCrush Security Scan

0 finding(s) in the 3 file(s) this pull request changes.

Nothing in the files this pull request changes.

56 pre-existing finding(s) elsewhere in the repository — **HIGH**: 3 | **MEDIUM**: 34 | **LOW**: 19

Not introduced by this pull request.

Severity Rule Location
HIGH deploy-compose-from-synced-repo .github/workflows/deploy-prober.yml:63
HIGH tls-verification-disabled lib/onion.ts:50
HIGH secret-generic-credential lib/sp/platforms/facebook.ts:32
MEDIUM gha-ssh-key-secret .github/workflows/deploy-dev2.yml:183
MEDIUM gha-ssh-key-secret .github/workflows/deploy-prober.yml:44
MEDIUM js-unescaped-html-sink app/(app)/dashboard/admin/email-broadcast/EmailBroadcastForm.tsx:125
MEDIUM js-unescaped-html-sink app/(app)/dashboard/projects/[id]/autoblog/articles/[articleId]/page.tsx:214
MEDIUM js-unescaped-html-sink app/(marketing)/blog/[slug]/page.tsx:74
MEDIUM js-unescaped-html-sink app/(marketing)/blog/[slug]/page.tsx:102
MEDIUM js-unescaped-html-sink app/(marketing)/recent/page.tsx:178
MEDIUM js-unescaped-html-sink app/(marketing)/recent/page.tsx:182
MEDIUM js-unescaped-html-sink app/c/[project]/[slug]/page.tsx:76
MEDIUM js-unescaped-html-sink app/c/[project]/page.tsx:58
MEDIUM js-unescaped-html-sink app/careers.js/route.ts:228
MEDIUM js-unescaped-html-sink app/careers.js/route.ts:285
MEDIUM js-unescaped-html-sink app/layout.tsx:139
MEDIUM js-open-redirect app/login/form.tsx:40
MEDIUM js-unescaped-html-sink app/r/[token]/page.tsx:177
MEDIUM js-open-redirect app/signup/form.tsx:65
MEDIUM js-unescaped-html-sink app/surveys/[slug]/invite/page.tsx:68

…and 36 more; the full set is in the SARIF artifact.

Snippets are redacted; ThreatCrush never prints matched credential material.

@ralyodio
ralyodio merged commit adb5a84 into master Nov 30, 2026
5 checks passed
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.

1 participant