Performance: Why Remix forms work without JavaScript
This concept affects page load speed and interaction responsiveness by enabling form submissions without relying on JavaScript.
<form method="post" action="/submit">...</form> using native HTML form submission handled by Remix server
<form onSubmit={handleSubmit}>...</form> with JavaScript handling submission and no fallback| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| JS-dependent form submission | Multiple event listeners and DOM updates | Triggers reflows on validation and dynamic UI changes | Higher paint cost due to JS-driven UI updates | [X] Bad |
| Native HTML form submission (Remix default) | Minimal DOM operations, uses browser default | Single reflow on page navigation | Low paint cost, no JS UI updates needed | [OK] Good |
<form method="post" action="/login"> <input name="username" /> <input name="password" type="password" /> <button type="submit">Login</button> </form>
<form onSubmit={handleSubmit}>
<input name="email" />
<button type="submit">Send</button>
</form>Pass the test and this pattern moves unknown