Make Intersection Observer / hydrate-client configurable
See original GitHub issueIn some of my use cases the intersection observer used to lazy load components with hydrate-client
kicked in a bit late. As I understand it @philipp-tailor had a similar issue in #12 in that he’d like components with hydrate-client
to hydrate instantly.
For these use cases it would be great if the hydrate-client
behavior would be configurable. I personally like the fact that lazy loading is the default. Maybe the behavior can be extended something like this:
<!-- Lazy load component when in view -->
<Component hydrate-client={{}} />
<!-- Hydrate instantly -->
<Component hydrate-client={{}} hydrate-lazy={ false } />
<!-- Lazy load component with specific intersection observer configuration -->
<Component hydrate-client={{}} hydrate-lazy={{ rootMargin: '500px' }} />
note: I see IntersectionObserver.ts
already accepts a distancePx
, but it’s not accessible from a Svelte template.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Intersection Observer API - MDN Web Docs
The Intersection Observer API provides a way to asynchronously observe changes in the intersection of a target element with an ancestor ...
Read more >Web Optimization using Intersection Observer API | by GP Lee
According to MDN, The Intersection Observer API provides a way to asynchronously observe changes in the intersection of a target element ...
Read more >JavaScript Intersection Observer Ultimate Guide
Intersection Observer is one of 3 observer based JavaScript APIs with the other two being Resize Observer and Mutation Observer.
Read more >Learn Intersection Observer In 15 Minutes - YouTube
Intersection Observer is an amazing tool in JavaScript that allows you to easily and efficiently do pretty much anything based on the ...
Read more >A guide to Intersection Observer | Uploadcare Blog
Let's see how to use Intersection Observer API to determine whether the DOM element ... options — an object with additional configuration.
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
Just another thought: to improve load time of a lazy component it would be nice if you could prioritize it using preloading:
This would add a
link[rel="preload"]
to the head stack:@jbmoelker We’ll rock “eager” and “lazy” then to match the spec. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attr-loading