Skip to content

CRITICAL: Fix script load order (app.js before Alpine)#29

Merged
Varnasr merged 1 commit into
mainfrom
claude/fix-script-order
May 27, 2026
Merged

CRITICAL: Fix script load order (app.js before Alpine)#29
Varnasr merged 1 commit into
mainfrom
claude/fix-script-order

Conversation

@Varnasr
Copy link
Copy Markdown
Owner

@Varnasr Varnasr commented May 27, 2026

Critical fix

The entire site was broken, not just dark mode. Root cause: app.js was at the end of <body> (line 1639) while Alpine was in <head> (line 174). Both used defer, and defer scripts execute in document order — so Alpine ran first, tried to call siteApp(), and failed because app.js hadn't loaded yet. Result: no tabs, no charts, no dark mode, no role selector, nothing.

Fix

Move <script defer src="app.js"> to <head>, before the Alpine script. Defer order is now:

  1. app.js (defines siteApp(), FALLBACK_DATA, helpers)
  2. Alpine (processes x-data="siteApp()", binds everything)
  3. ECharts (chart library, used lazily by app code)

Remove the duplicate app.js reference that was at end of body.

Test plan

  • Page loads and all tabs work
  • Dark mode toggle (Light / Device / Dark) works
  • Charts render in all tabs
  • Deep Analysis tab shows scorecard + charts
  • Scenario Lab sliders update the Sankey in real time

Generated by Claude Code

app.js was at line 1639 (end of body) while Alpine was at line 174
(head). Both had defer, and defer scripts execute in document order
-- so Alpine ran first, tried to call siteApp(), and failed because
app.js hadn't executed yet. This broke the entire site (not just
dark mode -- tabs, charts, role selector, everything).

Fix: move app.js to <head> BEFORE Alpine's script tag. Defer order
is now: app.js -> Alpine -> ECharts. Remove the duplicate reference
at end of body.

Also bumped SW cache name to sp-v3.0.1 and version meta to 3.0.1.
@Varnasr Varnasr merged commit d322754 into main May 27, 2026
1 check passed
@Varnasr Varnasr deleted the claude/fix-script-order branch May 27, 2026 15:13
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