Fix lazy-rendered charts staying blank on script load-order race#1332
Open
lucadobrescu wants to merge 2 commits into
Open
Fix lazy-rendered charts staying blank on script load-order race#1332lucadobrescu wants to merge 2 commits into
lucadobrescu wants to merge 2 commits into
Conversation
…egisters before render-facade fires (#1319) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
…es the delayed script loader Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1319
Root cause
visualizerLoadScripts()fetched allscript[data-visualizer-script]placeholders with paralleljQuery.getScript()calls, discarding the WordPress dependency order. Whenrender-facade.jsexecuted before the chart renderer (render-google.jsetc.), the facade fired its one-shotvisualizer:render:chart:startevent with no listener registered.all_chartswas 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 usingasync = 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_=timestampcache-busting on every page view, and one failed script no longer affects the others.Reproduction / verification
Deterministic repro: delay
render-google.jsby 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:page.route— fails on the old loader, passes with the fix🤖 Generated with Claude Code