Skip to content

Perf: Defer widget-schema prefetch AJAX to requestIdleCallback - #3

Draft
collinversluis wants to merge 1 commit into
mainfrom
claude/perf-pr3-defer-widget-schema-prefetch
Draft

Perf: Defer widget-schema prefetch AJAX to requestIdleCallback#3
collinversluis wants to merge 1 commit into
mainfrom
claude/perf-pr3-defer-widget-schema-prefetch

Conversation

@collinversluis

Copy link
Copy Markdown
Member

Summary

The widget-schema prefetch AJAX request fires synchronously during editor bootstrap, competing for the main thread with the initial render. Wrap it in requestIdleCallback (with setTimeout fallback for Safari) so it runs after the editor is interactive.

  • 1 file, ~25 LoC
  • The prefetch itself is unchanged — only the timing shifts
  • Falls back to immediate fire on browsers without requestIdleCallback

Impact

Moves ~200-400ms of network + JSON parse cost off the critical render path. Editor becomes interactive faster; the prefetched data is still ready by the time the user opens a widget panel.

Test plan

  • Open editor, immediately open a widget panel — verify panel populates (prefetch completes in time)
  • Open editor on Safari (no requestIdleCallback) — verify fallback path fires
  • Network panel shows the prefetch request firing after first contentful paint, not before

Notes

Cherry-pick from claude/great-mayer-klkFh. Conservative — only changes WHEN the request fires, not what it does.


Generated by Claude Code

Phase 5 of the perf series.

requestWidgetsConfig fetches ~394 KB of widget control schemas for widget types
NOT used on the page (in-page widgets already have their schemas in the boot
config). Currently fires synchronously during initEditor, so the response
parse + 394 KB jQuery.extend(true,{},...) deep-merge into widgetsCache races
with initial canvas render on the main thread.

This defers the entire request body + send + response processing into
requestIdleCallback (with a 3s timeout safety net, and setTimeout(0) fallback
for browsers without rIC). The only thing waiting on it is the panel-loading
spinner via panel/state-ready — the canvas is interactive immediately.

Gated by the existing e_memoize_active_controls experiment.
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