Performance: CSS bundling options
MEDIUM IMPACT
This affects page load speed by controlling how CSS files are combined and delivered to the browser.
/* app/assets/stylesheets/application.css */ /* Use Rails asset pipeline or CSS bundler to combine CSS into one file */ @import 'all_styles'; /* all_styles.css is a single bundled file containing reset, layout, colors, fonts */
/* app/views/layouts/application.html.erb */ <!-- Deliver many separate CSS files without bundling --> <%= stylesheet_link_tag 'reset' %> <%= stylesheet_link_tag 'layout' %> <%= stylesheet_link_tag 'colors' %> <%= stylesheet_link_tag 'fonts' %>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Multiple small CSS files | Low | Multiple reflows due to delayed style application | High paint cost due to late style application | [X] Bad |
| Single bundled CSS file | Low | Single reflow after styles applied | Lower paint cost as styles apply faster | [OK] Good |
| Full Tailwind CSS without purge | Low | Single reflow but delayed due to large CSS | High paint cost due to large CSS | [X] Bad |
| Tailwind CSS with purge enabled | Low | Single reflow with fast style application | Low paint cost due to small CSS | [OK] Good |