Open krishnaTORQUE opened 4 years ago
I'd do a PR, but I'm not sure this is the most optimal place to put the noscript
.
Clone the repo
Open LazyLoadImage.jsx
Replace this with the below code.
return (
<>
<LazyLoadComponent
beforeLoad={beforeLoad}
className={className}
delayMethod={delayMethod}
delayTime={delayTime}
height={height}
placeholder={placeholder}
scrollPosition={scrollPosition}
style={style}
threshold={threshold}
useIntersectionObserver={useIntersectionObserver}
visibleByDefault={visibleByDefault}
width={width}
>
{this.getImg()}
</LazyLoadComponent>
<noscript>{this.getImg()}</noscript>
</>
);
Profit
Actually, this is better.
LazyLoadImage.jsx
if (typeof window === "undefined") return <noscript>{this.getImg()}</noscript>;
return (
<>
<LazyLoadComponent
beforeLoad={beforeLoad}
className={className}
delayMethod={delayMethod}
delayTime={delayTime}
height={height}
placeholder={placeholder}
scrollPosition={scrollPosition}
style={style}
threshold={threshold}
useIntersectionObserver={useIntersectionObserver}
visibleByDefault={visibleByDefault}
width={width}
>
{this.getImg()}
</LazyLoadComponent>
</>
);
Describe the solution you'd like Server Side Rending. Send IMG tag directly to client