Performance: POST requests for form submission
MEDIUM IMPACT
This affects page load speed and interaction responsiveness when submitting forms.
methods: { async submitForm() { try { this.isLoading = true; const response = await fetch('/api/submit', { method: 'POST', body: JSON.stringify(this.formData), headers: { 'Content-Type': 'application/json' } }); const data = await response.json(); this.isLoading = false; this.successMessage = 'Submitted successfully!'; } catch { this.isLoading = false; this.errorMessage = 'Submission failed.'; } } }methods: { submitForm() { fetch('/api/submit', { method: 'POST', body: JSON.stringify(this.formData), headers: { 'Content-Type': 'application/json' } }).then(response => response.json()).then(data => { alert('Submitted!'); }).catch(() => { alert('Error'); }); } }| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Async fetch with alert | Minimal DOM changes | 0 reflows but blocks input | Blocks paint during alert | [X] Bad |
| Async fetch with reactive state | Updates loading and message nodes | 1 reflow for message update | Paint cost low and non-blocking | [OK] Good |