Skip to content

Commit 2aa269a

Browse files
committed
Add generated_component_packs_loading_strategy to base initializer template
Per feedback, this setting should be in the base template (not Pro-only): - Added to react_on_rails.rb.tt template with clear documentation - Default is :defer (recommended for most apps) - Documents that :async requires React on Rails Pro for better performance - Explains the differences between :defer, :sync, and :async - Prevents component registration race conditions with :defer default This ensures new Rails apps get the configuration with sensible defaults.
1 parent 4a8da30 commit 2aa269a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb.tt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,18 @@ ReactOnRails.configure do |config|
6464
# generated directory. default is false, you can pass option at the time of individual usage or update the default
6565
# in the following line
6666
config.auto_load_bundle = true
67+
68+
################################################################################
69+
# GENERATED COMPONENT PACKS LOADING STRATEGY
70+
################################################################################
71+
# Configure how generated component packs are loaded in the browser.
72+
# Options: :defer (default), :sync, :async
73+
#
74+
# - :defer (recommended for most apps): Scripts load in parallel but execute in order after HTML parsing
75+
# - :sync: Scripts block HTML parsing (not recommended)
76+
# - :async: Scripts load and execute as soon as available (requires React on Rails Pro for better performance)
77+
#
78+
# Default is :defer which provides good performance and prevents component registration race conditions.
79+
# For React on Rails Pro users, :async can provide better performance by loading scripts asynchronously.
80+
config.generated_component_packs_loading_strategy = :defer
6781
end

0 commit comments

Comments
 (0)