Performance: Why asset management matters
HIGH IMPACT
This affects page load speed by controlling how CSS, JavaScript, and images are loaded and cached.
Use Rails asset pipeline or import maps to bundle assets: <%= stylesheet_link_tag 'application', 'data-turbo-track' => 'reload' %> <%= javascript_include_tag 'application', 'data-turbo-track' => 'reload', defer: true %>
In application.html.erb: <%= stylesheet_link_tag 'style1' %> <%= stylesheet_link_tag 'style2' %> <%= javascript_include_tag 'script1' %> <%= javascript_include_tag 'script2' %>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Multiple separate CSS/JS files | N/A | Blocks rendering until all loaded | High due to delayed paint | [X] Bad |
| Bundled and deferred assets | N/A | Single render-blocking point, then non-blocking | Lower paint cost, faster LCP | [OK] Good |