Performance: CSS bundling options
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 |
rails css:install:<bundler> to install a CSS bundler.rails css:install:tailwind.rails css:install:bootstrap, what is the expected outcome?rails css:install:bootstrap installs Bootstrap CSS bundling support in the Rails app.rails css:install:sass but get an error. What is the likely cause?rails css:install:bootstrap to add Bootstrap bundling setup.Pass the test and this pattern moves unknown