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
Recommend async + immediate_hydration even for non-streaming pages
- Update documentation to clarify that defer: true is suboptimal even for non-streaming pages
- Recommend async: true with immediate_hydration for best Time to Interactive
- Add section about generated_component_packs_loading_strategy config
- Update dummy app comment to explain why defer is used (test compatibility) but async is recommended for production
Co-authored-by: Abanoub Ghadban <AbanoubGhadban@users.noreply.github.com>
With `async: true` and the `immediate_hydration` Pro feature enabled, your components hydrate as soon as they're available—before the full page finishes loading. This provides optimal Time to Interactive (TTI) for both streaming and non-streaming pages.
247
+
248
+
**Alternative for Non-Pro or Pre-8.2.0 Shakapacker:**
249
+
250
+
```erb
251
+
<!-- ✅ GOOD: No defer - allows components to hydrate early -->
While `defer: true` won't defeat Selective Hydration on non-streaming pages (since there's no streaming to defeat), it still delays all component hydration until after the complete page loads, resulting in slower Time to Interactive.
263
+
264
+
#### Using generated_component_packs_loading_strategy Config
265
+
266
+
Instead of manually specifying `async: true` on each `javascript_pack_tag`, you can configure the loading strategy globally for auto-generated component packs:
267
+
268
+
```ruby
269
+
# config/initializers/react_on_rails.rb
270
+
ReactOnRails.configure do |config|
271
+
# Set loading strategy for auto-generated component packs
# Enable immediate hydration (React on Rails Pro feature)
276
+
# Components hydrate as soon as their HTML arrives, without waiting for full page load
277
+
config.immediate_hydration =true
278
+
end
279
+
```
280
+
281
+
This configuration applies to components rendered with auto-generated packs. For manual `javascript_pack_tag` calls, you'll still need to specify `async: true` explicitly.
282
+
283
+
#### Why Async is Better
257
284
258
-
With Shakapacker ≥ 8.2.0, using `async: true` provides the best performance:
285
+
With Shakapacker ≥ 8.2.0 and React on Rails Pro, using `async: true` + `immediate_hydration: true` provides the best performance:
259
286
260
-
-**No defer/async**: Scripts block HTML parsing and streaming
0 commit comments