Skip to content

Commit d4e8802

Browse files
ystemsrxclaude
andcommitted
fix(landing): drop top-level await so window.load handler binds in time
The earlier fix used `await import(...)` to defer prism-sql until after window.Prism was assigned. Top-level await turned the inline module into an asynchronous evaluation, which let `window.load` fire before the `addEventListener("load", buildHeroGraph)` line ran — so on Pages the hero ER graph never built and the canvas stayed blank with no console error. Use fire-and-forget dynamic import; syntax highlighting can fail silently without taking the hero down with it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 7922b84 commit d4e8802

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

index.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,9 +1962,12 @@ <h2 class="cta-title" data-i18n-html="cta_title">
19621962
import * as Layout from "./src/layout";
19631963

19641964
// prism-sql 在模块顶层引用全局 Prism;ESM 下 prismjs 不会自挂 window,
1965-
// 必须先把核心赋到全局,再用动态 import 让语言定义晚于赋值执行。
1965+
// 必须先把核心赋到全局,再动态 import 让语言定义晚于赋值执行。
1966+
// 不要用 top-level await:那会把整个模块变成异步求值,导致下方
1967+
// window.addEventListener("load", ...) 在 load 事件之后才注册,
1968+
// Hero ER 图永远不会被构建。代码高亮失败也不应阻塞主流程。
19661969
window.Prism = Prism;
1967-
await import("prismjs/components/prism-sql");
1970+
import("prismjs/components/prism-sql").catch(() => {});
19681971

19691972
// ───── YEAR ─────
19701973
document.getElementById("year").textContent = new Date().getFullYear();

0 commit comments

Comments
 (0)