0
0
Ruby on Railsframework~8 mins

Rails new project generation - Performance & Optimization

Choose your learning style9 modes available
Performance: Rails new project generation
MEDIUM IMPACT
This affects the initial load speed and bundle size of a Rails web application by determining which components and assets are included from the start.
Creating a new Rails project with only needed components
Ruby on Rails
rails new myapp --skip-action-mailbox --skip-action-text --skip-active-storage --skip-javascript
Skips unused components, reducing bundle size and asset compilation time, leading to faster initial page load.
📈 Performance GainSaves 500-1000KB in assets, reduces LCP by 200-400ms
Creating a new Rails project with only needed components
Ruby on Rails
rails new myapp
Generates a full Rails app with all default components, including unused JavaScript frameworks, CSS, and Active Storage, increasing bundle size and load time.
📉 Performance CostAdds 1-2MB to initial bundle size, increasing LCP by 300-500ms on slow networks
Performance Comparison
PatternDOM OperationsReflowsPaint CostVerdict
Full default Rails projectModerate (default views and scripts)Multiple reflows due to larger CSS/JSHigher paint cost from bigger assets[X] Bad
Rails project with skipped unused componentsMinimal DOM from leaner viewsSingle reflow from optimized CSS/JSLower paint cost due to smaller assets[OK] Good
Rendering Pipeline
The Rails new project generation determines which assets and code are included in the initial HTML, CSS, and JavaScript sent to the browser. More components mean more files to compile and send, affecting the browser's parsing and rendering speed.
Network Transfer
HTML Parsing
CSSOM Construction
JavaScript Execution
⚠️ BottleneckNetwork Transfer and JavaScript Execution due to larger asset bundles
Core Web Vital Affected
LCP
This affects the initial load speed and bundle size of a Rails web application by determining which components and assets are included from the start.
Optimization Tips
1Skip unused Rails components to reduce initial asset size.
2Smaller bundles improve Largest Contentful Paint (LCP).
3Avoid including unnecessary JavaScript frameworks at project start.
Performance Quiz - 3 Questions
Test your performance knowledge
What is a performance downside of generating a Rails project with all default components?
AIt reduces the number of HTTP requests
BIt improves JavaScript execution speed
CLarger initial asset size increases page load time
DIt decreases CSS complexity
DevTools: Network
How to check: Open DevTools, go to Network tab, reload the page, and observe the size and number of asset files loaded.
What to look for: Look for large JavaScript and CSS files that delay page load; smaller bundles indicate better performance.