loading="lazy" #185
Replies: 1 comment
|
Hey, Just documenting here before closing.
Supporting this in the library would mean rendering an observable placeholder element (for an It composes cleanly in app code, where you own the placeholder element (which you need for layout/sizing anyway): import { useInView } from 'react-intersection-observer';
import InlineSVG, { Props } from 'react-inlinesvg';
function LazySVG(props: Props) {
const { ref, inView } = useInView({ triggerOnce: true, rootMargin: '200px' });
return <span ref={ref}>{inView && <InlineSVG {...props} />}</span>;
} |
Uh oh!
There was an error while loading. Please reload this page.
There is an attribute
loadinginimgelement withlazyoption.It would be great to have that attribute with same options for inlineSvg.
I have quite a big set of SVGs, and it would be more optimal only load them when they are visible after scrolling. I can solve that by implementing infinite scroll behavior on my side. But
loading="lazy"would be the simplest solutionAll reactions