Reputation:
I have a component which loads some images. It's not expensive at all, but I don't want them to appear one by one from top to bottom, if you know what I mean. Is it considered a bad practice to use lazy()
and Suspense
for that?
Thanks in advance!
Upvotes: 2
Views: 1179
Reputation: 2341
If you have specific component for rendering Image in react , the best ways of lazy loading is using lazy() import
or Suspense
.
Although , there is a more recent way of doing this with HTML and it is appropriate for inline <img/>
tags.
<img loading="lazy"/>
// also works for iframe
<iframe loading="lazy"/>
keep in the mind that this attribute, at present , is only available in chrome
and firefox
Upvotes: 1