Performance: Why forms drive user interaction
Forms impact how quickly users can interact with a page and how smoothly the page responds to input.
form_with url: '/submit', method: :post, local: true, data: { turbo: false } do |form| = form.text_field :name = form.submit 'Send' end # Submits synchronously with minimal DOM updates
form_with url: '/submit', method: :post, local: false do |form| = form.text_field :name = form.submit 'Send' end # Submits via AJAX but triggers full page re-render on response
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| AJAX form with full page re-render | High (many nodes updated) | Multiple reflows | High paint cost | [X] Bad |
| Synchronous form with minimal DOM update | Low (only form elements) | Single reflow | Low paint cost | [OK] Good |
form_with for a model named @post?model: followed by the model instance.form_with model: @post do |form| uses model: @post, which is correct. form_with model @post do |form| misses the colon after model. Options C and D use incorrect keywords.form_with model: @user do |form| form.text_field :name form.submit 'Save' end
form_with model: @article do |f| f.text_field :title f.submit end
form_with option correctly sets this up?form_with url: feedback_path, method: :post do |form| uses url: and method: correctly. Options A and D use invalid keywords. form_with model: @feedback do |form| expects a model, which is not present.Pass the test and this pattern moves unknown