diff --git a/kitsune/sumo/jinja2/base.html b/kitsune/sumo/jinja2/base.html index abbff340d41..c88868ae7df 100644 --- a/kitsune/sumo/jinja2/base.html +++ b/kitsune/sumo/jinja2/base.html @@ -3,8 +3,14 @@ {% if request.LANGUAGE_CODE == 'xx' %} {% set meta = [('robots', 'noindex')] %} {% endif %} +{# Read the theme cookie set by theme-toggle.js so we can pre-render the correct #} +{# data-theme and background inline — this eliminates a potential navigation flash entirely #} +{# because the HTML arrives from the server already styled, before any JS runs. #} +{% set _theme_cookie = request.COOKIES.get('sumo-theme', '') %} +{% set _is_dark = _theme_cookie == 'dark' %} + {# ============================================================ #} + {# Theme flash prevention #} + {# Primary: data-theme + style are pre-rendered by Django from #} + {# the sumo-theme cookie (set by theme-toggle.js on toggle). #} + {# Fallback: inline style + script cover first-time visitors #} + {# (no cookie yet) who rely on OS dark mode. #} + {# #1C1B22 = --color-dark-gray-09 = --page-bg in dark mode. #} + {# ============================================================ #} + + {# Fallback for first-time OS-dark visitors with no cookie yet. #} + + {% include "includes/google-analytics.html" %} {% block head_top %}{% endblock %} @@ -137,6 +165,19 @@ {% endif %} +
+ +
+