Performance: Stimulus and Turbo (Hotwire)
MEDIUM IMPACT
This affects page load speed by reducing full page reloads and improves interaction responsiveness by updating only parts of the page.
<button data-action="click->controller#update">Update</button> import { Controller } from '@hotwired/stimulus' export default class extends Controller { update() { fetch('/partial_update') .then(response => response.text()) .then(html => { this.element.outerHTML = html }) } }
document.querySelector('#button').addEventListener('click', () => { window.location.reload(); });
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Full page reload on interaction | High (entire DOM replaced) | Multiple (full page) | High (full repaint) | [X] Bad |
| Turbo partial page update | Low (only changed fragments) | Single or few (targeted) | Low (partial repaint) | [OK] Good |
| Stimulus event-driven update | Low (targeted elements) | Single | Low | [OK] Good |