Skip to content

Comments

fix: eliminate banner flash on page reload#663

Open
RisingOrange wants to merge 6 commits intoPauseAI:mainfrom
RisingOrange:banner-flash
Open

fix: eliminate banner flash on page reload#663
RisingOrange wants to merge 6 commits intoPauseAI:mainfrom
RisingOrange:banner-flash

Conversation

@RisingOrange
Copy link
Contributor

@RisingOrange RisingOrange commented Feb 21, 2026

Closes #665

Problem

When a dismissed banner is reloaded, it briefly flashes visible before disappearing. This happens because the server renders the banner as visible, the browser paints it, and only then does JS hydrate and hide it based on localStorage.

2026-02-21.20-53-24.mp4

Solution

Same technique as the existing dark mode no-flash init: add an inline blocking <script> in app.html that runs synchronously before first paint, reads localStorage, and injects CSS to hide dismissed banners immediately.

  • Add data-banner-id and data-campaign-banner-id attributes to banner elements so the CSS can target them
  • Move Banner.svelte hidden state from onMount to initialization time (eliminates the flash window between hydration and mount)
  • Guard all init-time localStorage reads with try-catch to handle storage-restricted contexts (Firefox strict mode, Safari ITP, etc.)
  • Remove debug console.logs and buggy global DOM click listener from Banner.svelte
  • Remove stale india-summit-2026 localStorage setter from +layout.svelte (banner no longer exists; CampaignBanner already self-hides on its own page)

Test plan

  • Dismiss a banner, reload — banner should not flash
  • DevTools → Application → Local Storage → clear banner keys → reload → banner appears normally
  • Dismiss again, navigate away, navigate back → still hidden, no flash
  • DevTools → Elements → <head> should contain a <style> tag with display:none!important rules when localStorage has dismissed banners
  • Fresh visitor (no localStorage keys) — banner renders normally, no regressions

…rst paint

Add an inline blocking script in app.html that reads localStorage before
first paint and injects display:none CSS for any dismissed banners. Add
data-banner-id and data-campaign-banner-id attributes to banner elements
for CSS targeting. Move Banner.svelte's hidden state check from onMount to
initialization time. Remove debug console.logs and buggy global DOM click
listener from Banner.svelte. Remove stale india-summit-2026 localStorage
setter from layout.svelte.
@netlify
Copy link

netlify bot commented Feb 21, 2026

👷 Deploy request for pauseai pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit f4787d1

@RisingOrange RisingOrange marked this pull request as ready for review February 21, 2026 20:38
@RisingOrange RisingOrange mentioned this pull request Feb 21, 2026
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.

Banner flashes briefly on page reload when previously dismissed

1 participant