Performance: Action functions for mutations
MEDIUM IMPACT
This affects how quickly the page responds to user input and updates data on the server, impacting interaction speed and page responsiveness.
export async function action({ request }) { const formData = await request.formData(); await updateData(formData); // mutation handled server-side return json({ success: true }); } // Client-side: use fetcher.submit() to call action without full reload
export async function loader() { // Fetch data return fetchData(); } export async function action({ request }) { const formData = await request.formData(); await updateData(formData); // mutation inside action return redirect('/'); } // Client-side: form submits normally, page reloads
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Full page reload after action | High (reloads entire DOM) | Multiple reflows | High paint cost | [X] Bad |
| Using fetcher.submit() for action | Low (partial update) | Single reflow | Low paint cost | [OK] Good |