You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix FOUC using content_for to ensure proper pack tag ordering
Problem:
- Stylesheets at bottom of body caused FOUC with SSR
- Moving to head failed because react_component (with auto_load_bundle)
calls append_*_pack_tag during render, which must execute before
the main *_pack_tag helpers
Solution:
- Use content_for :head block in body for explicit append calls
- yield :head in head section before calling main pack tags
- This ensures all appends (explicit + auto from react_component)
execute before main pack tags, allowing styles in head
- Keeps auto_load_bundle enabled for automatic component packs
Changes:
- Wrap append_*_pack_tag calls in content_for :head blocks
- Add yield :head in head section before pack tags
- Move stylesheet_pack_tag and javascript_pack_tag to head
- Applied to both application.html.erb and stimulus_layout.html.erb
Result: Stylesheets load in head, eliminating FOUC while maintaining
auto_load_bundle functionality.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
0 commit comments