Turbo Frames lazy loading request count for low-traffic Rails pages
0 reputation · 28 May 2026, 03:06 UTC
0 reputation · 28 May 2026, 03:06 UTC
Turbo Frames support deferred loading through the loading='lazy' attribute on turbo_frame_tag in Rails 7.1 and later. The objective is to lower initial-page bandwidth and server requests for a low-traffic workload by fetching offscreen frame content only when it enters the viewport.
Each lazy frame currently issues an independent HTTP GET to its src URL on scroll, and Turbo does not include a built-in option to batch or merge multiple frame fetches into one response. Fragment caching and Cache-Control headers work per endpoint, but request volume still grows with the number of frames on the page.
Can multiple lazy Turbo Frame fetches be consolidated into a single request through any supported configuration? Should above-the-fold frames use loading='eager' while only secondary sections defer loading, and how does that choice affect authenticated endpoints and search-engine indexing?
34775 reputation · 28 May 2026, 13:29 UTC
There is currently no native configuration in Turbo (Rails 7.1+) to batch or consolidate multiple loading='lazy' Turbo Frame fetches into a single HTTP request. By design, each frame with a src attribute operates as an independent unit; when the Intersection Observer triggers, Turbo issues a separate GET request for that specific frame's source.
The current behavior is a result of Turbo's decoupled architecture, where each frame manages its own lifecycle. If request volume is a bottleneck for your low-traffic workload, consider these architectural alternatives:
You should use eager loading (the default) for all above-the-fold content. Deferring initial viewport content leads to Cumulative Layout Shift (CLS) and a poor perceived user experience.
| Factor | Eager (Above-the-Fold) | Lazy (Below-the-Fold) |
|---|---|---|
| SEO | Indexed normally as part of initial HTML. | Generally ignored by crawlers as they rarely trigger JS intersection events. |
| Auth | Validated during initial page load. | Each request triggers the full Rails middleware stack and session check. |
| UX | Immediate visibility. | Reduced initial bandwidth; potential "pop-in" on scroll. |
To confirm the request behavior in your specific environment:
Fetch/XHR.turbo-frame triggers a unique request to its src URL.tail -f log/development.log to see the independent controller actions being invoked.Diagnostic Question: Are these lazy frames targeting the same controller action with different parameters, or entirely different endpoints? (If they share an action, a custom batching endpoint may be easier to implement).
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.