turbo-frame loading=lazy loads eagerly in Safari
See original GitHub issueIt appears that the IntersectionObserver
in Safari fires immediately on custom HTML elements. For some apps using lazy turbo frames, this is effectively graceful degradation (which is great!) but there have been a few blog posts written about using lazy turbo frames for infinite scroll (this one, for example, which links to a couple others).
In this use case, due to this issue in Safari, infinite-scrolling feeds will continue loading forever until the user reaches the bottom of the feed, the server rate-limits them, or their browser crashes.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Lazy-loading content with Turbo Frames and skeleton loader
Additionally, you can set the loading property of the loading to be either “eager” (load right away) or “lazy” (load once the frame...
Read more >Lazy-loaded frame - Turbo Reference
A reference of everything you can do with Turbo Frames. ... Like an eager-loaded frame, but the content is not loaded from src...
Read more >Cross Browser Compatibility of Lazy loading via attribute for ...
Lazy loading via attribute for images & iframes is Not Supported on Safari 14, which means that any user who'd be accessing your...
Read more >#11 Turbo Frames - Load content only when a dropdown is ...
If a page has a turbo frame with lazy loading, the lazy loading will occur only when the frame element becomes not “hidden”....
Read more >Untitled
#Lazy Hartley's olde english marmalade, O2 one concert retrospect, Brede heupen krijgen, ... Lazy loading eager loading java, Sets and venn diagrams tes!...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Then I think your question has landed in the wrong place. This issue is about
<turbo-frame loading=lazy>
.@filipemendespi None that I’ve tested, unfortunately. Turbo Frames being implemented in terms of custom elements is a fundamental design decision. As a workaround, you might be able to attach an
IntersectionObserver
to a standard element with a Stimulus controller and have that observer attach thesrc
attribute to theturbo-frame
element. I don’t know if that will work, but the basic idea is this:On page load:
When
my-frame-observer
hits the viewport:I believe this should kick off the request as expected, but I haven’t tested it yet. Note that this is just the HTML part of it and it doesn’t include any Stimulus wiring or even vanilla JS event handlers you’d have to implement. If I can test it out some time this week, I’ll update this thread.