From 239125a8e568da7357f195a55dd158b39ba30859 Mon Sep 17 00:00:00 2001 From: Tyler Hallada Date: Fri, 4 Sep 2026 19:08:52 +0000 Subject: [PATCH] Put theme.js after the stylesheet so Gecko cannot paint unstyled Root cause of the Firefox-only flash of blue links on the first click after an idle spell (Bugzilla 1459305, still open): Gecko does not block the parser on a pending stylesheet, it only suppresses painting, and any layout flush in that window (an extension content script, a ResizeObserver, a getComputedStyle) initialises layout and paints the unstyled body. With theme.js *before* the , nothing stalled the parser while app.css was coming back from the disk cache, so the whole body was parsed unstyled and one flush painted it. Chrome blocks rendering on the sheet outright, which is why it never showed this. Gecko refuses to run a parser-blocking script while stylesheets are pending, so a synchronous script placed after the stalls the parser inside : there is nothing to paint. theme.js still runs before any body content exists, so has-js and the saved theme are applied pre-paint exactly as before. Reproduced with Playwright Firefox, a proxy delaying app.css and an init script forcing offsetHeight on every mutation: a 1.2 s unstyled paint with the old order, none with the new order, in both Firefox and Chromium. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01MD4VWGq6mGcd8Bg67qyx9k --- src/web/templates/layout.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/web/templates/layout.html b/src/web/templates/layout.html index 5cc6b66..f5d1ff8 100644 --- a/src/web/templates/layout.html +++ b/src/web/templates/layout.html @@ -5,8 +5,12 @@ {{ page.title }} ยท The Daily EPUB - + {# Keep this synchronous script *after* the stylesheet: Gecko will not run a + parser-blocking script while a stylesheet is pending, so the parser stalls + here and nothing unstyled exists to paint if something forces a layout + flush (Bugzilla 1459305). Chrome blocks rendering on the sheet regardless. #} +