Front-end performance fixes
Send the component code and describe what feels slow, and have Grok 4.6 point to what re-runs on each interaction and how to stop it. Check the result with the browser’s performance profiler before and after.
Example: Why does the chart lag while I type?
Material
- SalesChart.tsx
- const points = buildPoints(rows.filter(r => r.name.includes(query))); chart.setData(points);
- Symptom
- With 20,000 rows, each keystroke in the search box freezes the page for about half a second.
PromptUsing the component code and the symptom, explain why typing in the search box is slow and give the smallest fix.
Sample answer · written by hand to show the reasoning
Every keystroke filters all 20,000 rows and rebuilds the chart points during render. Wrap the filter and buildPoints in useMemo keyed on rows and query, and debounce the query by about 200 ms so the chart only rebuilds after typing pauses. Profile a keystroke again to confirm the long task is gone.