Skip to content

Commit b5f692f

Browse files
committed
Improve docs
1 parent e2bfd5c commit b5f692f

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed

docs/guides/file-system-based-automated-bundle-generation.md

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -466,11 +466,28 @@ Now when you visit your pages, React on Rails automatically:
466466
- Registers components without manual `ReactOnRails.register()` calls
467467
- Enables optimal bundle splitting and caching
468468

469-
**Bundle sizes in this example:**
470-
- HelloWorld: ~50KB (lightweight)
471-
- HeavyMarkdownEditor: ~2.7MB (heavy with 58+ dependencies)
469+
**Bundle sizes in this example (measured from browser dev tools):**
470+
- **HelloWorld**: 1.1MB total resources (50KB component-specific code + shared React runtime)
471+
- HelloWorld.js: 10.0 kB
472+
- HelloWorld.css: 2.5 kB
473+
- Shared runtime: ~1.1MB (React, webpack runtime)
474+
- **HeavyMarkdownEditor**: 2.2MB total resources (2.7MB with markdown libraries)
475+
- HeavyMarkdownEditor.js: 26.5 kB
476+
- HeavyMarkdownEditor.css: 5.5 kB
477+
- Markdown libraries: 1,081 kB additional
478+
- Shared runtime: ~1.1MB (React, webpack runtime)
472479

473-
Each page loads only what it needs!
480+
**Bundle splitting benefit**: Each page loads only its required components - the HelloWorld page doesn't load the heavy markdown libraries, saving ~1.1MB (50% reduction)!
481+
482+
#### Performance Screenshots
483+
484+
**HelloWorld (Lightweight Component):**
485+
![HelloWorld Bundle Analysis](../images/bundle-splitting-hello-world.png)
486+
487+
**HeavyMarkdownEditor (Heavy Component):**
488+
![HeavyMarkdownEditor Bundle Analysis](../images/bundle-splitting-heavy-markdown.png)
489+
490+
*Screenshots show browser dev tools network analysis demonstrating the dramatic difference in bundle sizes and load times between the two components.*
474491

475492
### Server Rendering and Client Rendering Components
476493

@@ -505,11 +522,19 @@ As of version 13.3.4, bundles inside directories that match `config.components_s
505522

506523
**Problem**: Components load but CSS styles are missing or delayed.
507524

525+
**Important**: FOUC (Flash of Unstyled Content) **only occurs with HMR (Hot Module Replacement)**. Static and production modes work perfectly without FOUC.
526+
508527
**Solutions**:
509-
- **Development with HMR**: FOUC is expected. Use `bin/dev static` mode for development without FOUC
510-
- **Production**: Ensure CSS extraction is working by checking for `.css` files in `public/packs/css/generated/`
511-
- **Layout**: Verify your layout includes empty `<%= stylesheet_pack_tag %>` placeholder
512-
- Check that CSS files are properly imported in your components: `import styles from './Component.module.css';`
528+
- **Development with HMR** (`./bin/dev`): FOUC is expected behavior due to dynamic CSS injection - **not a bug**
529+
- **Development static** (`./bin/dev static`): No FOUC - CSS is extracted to separate files like production
530+
- **Production** (`./bin/dev prod`): No FOUC - CSS is extracted and optimized
531+
- **Layout**: Verify your layout includes empty `<%= stylesheet_pack_tag %>` placeholder for CSS injection
532+
- **Component imports**: Check that CSS files are properly imported: `import styles from './Component.module.css';`
533+
534+
**Key insight**: Choose your development mode based on your current needs:
535+
- Use HMR for fastest development (accept FOUC)
536+
- Use static mode when testing styling without FOUC
537+
- Use production mode for final testing
513538

514539
#### 3. "document is not defined" errors during SSR
515540

403 KB
Loading

0 commit comments

Comments
 (0)