Skip to content

Fix lazy-rendered charts staying blank on script load-order race#1332

Open
lucadobrescu wants to merge 2 commits into
developmentfrom
fix/visualizer
Open

Fix lazy-rendered charts staying blank on script load-order race#1332
lucadobrescu wants to merge 2 commits into
developmentfrom
fix/visualizer

Conversation

@lucadobrescu

Copy link
Copy Markdown

Closes #1319

Root cause

visualizerLoadScripts() fetched all script[data-visualizer-script] placeholders with parallel jQuery.getScript() calls, discarding the WordPress dependency order. When render-facade.js executed before the chart renderer (render-google.js etc.), the facade fired its one-shot visualizer:render:chart:start event with no listener registered. all_charts was never set, so every later resize-based recovery iterated an empty object — the chart stayed blank until a full page reload.

Fix

Replace each placeholder with a real <script> element using async = false: browsers download the scripts in parallel but execute them in insertion order, which is the order WordPress printed them (renderer before facade). Side benefits: no more _=timestamp cache-busting on every page view, and one failed script no longer affects the others.

Reproduction / verification

Deterministic repro: delay render-google.js by a few seconds (slow CDN / cache-miss simulation), load a page with a lazy-render chart, interact. Before: blank forever. After: renders once scripts arrive. Verified with free 4.0.4 alone and with Visualizer Pro 2.0.1 active.

Tests

New tests/e2e/specs/lazy-render.spec.js:

  • race regression: renderer scripts delayed 2s via page.route — fails on the old loader, passes with the fix
  • sanity: same flow without delay

🤖 Generated with Claude Code

…egisters before render-facade fires (#1319)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@lucadobrescu lucadobrescu self-assigned this Jul 8, 2026
@lucadobrescu lucadobrescu added the pr-checklist-skip Allow this Pull Request to skip checklist. label Jul 8, 2026
@pirate-bot pirate-bot added the pr-checklist-complete The Pull Request checklist is complete. (automatic label) label Jul 8, 2026
@pirate-bot

pirate-bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Plugin build for f7a18e6 is ready 🛎️!

…es the delayed script loader

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-checklist-complete The Pull Request checklist is complete. (automatic label) pr-checklist-skip Allow this Pull Request to skip checklist.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants