Gathering detailed insights and metrics for @lambrioanpm/magni-magnam-rem
Gathering detailed insights and metrics for @lambrioanpm/magni-magnam-rem
Gathering detailed insights and metrics for @lambrioanpm/magni-magnam-rem
Gathering detailed insights and metrics for @lambrioanpm/magni-magnam-rem
npm install @lambrioanpm/magni-magnam-rem
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
3,060 Commits
1 Watchers
1 Branches
1 Contributors
Updated on May 23, 2025
Latest Version
1.0.0
Package Id
@lambrioanpm/magni-magnam-rem@1.0.0
Unpacked Size
22.67 kB
Size
7.52 kB
File Count
8
NPM Version
10.5.0
Node Version
20.12.2
Published on
May 05, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
30
Welcome to the React Vanilla Lazyload repo! Yes, the name is a bit of a head-scratcher 😅. But fear not, despite the contradiction, the story behind this oddly fitting name: we're using a fantastic script called Vanilla LazyLoad to lazily load our images in React.
So, even though React isn't exactly vanilla, this little module does its job beautifully... Get ready to turbocharge your React apps!... with React "Vanilla" LazyLoading.
1npm install @lambrioanpm/magni-magnam-rem
To enable the lazy loading in your app import the VanillaLazyLoad
component or use LazyWrapper
to wrap your lazy components.
The difference between VanillaLazyLoad
and LazyWrapper
is that LazyWrapper
is a wrapper component that wraps all lazy components in your app, use it in case you want to limit the scope of your lazy components.
Note that the lazy-loaded elements should not be in the initial viewport to avoid LCP or FID issues.
So in short, you can do the following:
1 <> 2 {/* The rest of the app */} 3 <VanillaLazyLoad/> 4 </>
OR if you want to limit the scope of your lazy components:
1 <LazyWrapper> 2 {/* The components that contains the lazy components */} 3 </LazyWrapper>
VanillaLazyLoad
- This is the main script that you need to import and add to your app footer to use it.LazyWrapper
- This is a wrapper component that wraps all lazy components. this replaces the VanillaLazyLoad component. This is useful in case you want to use it inside a wrapperLazyEl
- This component is used to lazy load any element, has a set of props that can be used to customize the lazy load (i.e. srcBg srcBgHDPI, dataBgMulti, dataBgMultiHidpi) used for backgrounds. typed as html elementLazyImg
- This component is used to lazy load images. typed as imageLazyVideo
- This component is used to lazy load videos. typed as videoLazyIframe
- This component is used to lazy load iframes. typed as iframeLazyModule
- This component is used to lazy load React Components. typed as React ComponentCheck out the Examples to get started.
If you want to use the VanillaLazyLoad
component, you can use it in your app footer and after all the lazy components.
1import React from "react"; 2import {VanillaLazyLoad, LazyEl} from "@lambrioanpm/magni-magnam-rem"; 3 4const App = () => { 5 return ( 6 <> 7 {/* The rest of the app */} 8 <LazyImg src={"https://github.com/lambrioanpm/magni-magnam-rem/demos/images/440x560-01.webp"} width={440} height={560}/> 9 <VanillaLazyLoad/> 10 </> 11 ); 12}; 13 14export default App;
If you want to use the LazyWrapper
component, you can use it in your app footer.
1import React from 'react'; 2import { 3 LazyWrapper, 4 LazyImg, 5 LazyVideo, 6 LazyIframe, 7 LazyEl, 8 LazyModule 9} from "@lambrioanpm/magni-magnam-rem"; 10 11const MyComponent = () => { 12 return ( 13 <LazyWrapper> 14 {/* The Lazy components are here */} 15 <LazyImg src={"https://github.com/lambrioanpm/magni-magnam-rem/demos/images/440x560-01.webp"} width={440} height={560}/> 16 </LazyWrapper> 17 ); 18}; 19 20export default MyComponent;
1 2import React from 'react'; 3import { 4 LazyWrapper, 5 LazyImg, 6 LazyVideo, 7 LazyIframe, 8 LazyEl, 9 LazyModule 10} from "@lambrioanpm/magni-magnam-rem"; 11 12const MyComponent = () => { 13 return ( 14 <LazyWrapper> 15 {/** Image */} 16 <LazyImg src={"https://github.com/lambrioanpm/magni-magnam-rem/demos/images/440x560-01.webp"} width={440} height={560}/> 17 {/** Iframe */} 18 <LazyIframe src={"https://github.com/lambrioanpm/magni-magnam-rem/demos/iframes/i01.html"} title={"iframe"} /> 19 {/** Video */} 20 <LazyVideo src={"https://github.com/lambrioanpm/magni-magnam-rem/demos/videos/1920x1080-01.mp4"} poster={"https://github.com/lambrioanpm/magni-magnam-rem/demos/images/440x560-01.webp"}/> 21 {/** HTML Element */} 22 <LazyEl bg={"https://github.com/lambrioanpm/magni-magnam-rem/demos/images/440x560-01.webp"}/> 23 {/** React Component */} 24 <LazyModule component={import('src/components/MyComponent.tsx')} loader={<Loading/>}/> 25 </LazyWrapper> 26 ); 27}; 28 29export default MyComponent;
LazyImg, LazyVideo, LazyIframe are used to lazy load images, videos and iframes. They are typed as html element, image, video and iframe respectively.
Those components are designed as a drop-in replacement for the vanilla img
, video
, iframe
elements you can use in your app simply replacing the tag img
, video
, iframe
with LazyImg
, LazyVideo
, LazyIframe
.
LazyEl is used to lazy load any element, has a set of props that can be used to customize the lazy load (i.e. srcBg srcBgHDPI, dataBgMulti, dataBgMultiHidpi) used for backgrounds. It is typed as html element.
bg
- The source of the backgroundbgHidpi
- The source of the hidpi backgroundbgMulti
- The source of the background for multi resolutionbgMultiHidpi
- The source of the background for multi resolution and hidpi1<LazyEl srcBg={"https://github.com/lambrioanpm/magni-magnam-rem/demos/images/440x560-01.webp"}/>
LazyModule is used to lazy load React Components.
component
- A function that returns a React Componentloader
- A React Component that will be rendered while the component is loading1<LazyModule component={import('src/components/MyComponent.tsx')} loader={<Loading/>}/>
Example | Code | Demo |
---|---|---|
demo | demo.tsx | demo |
animated | animated.tsx | demo |
images | images.tsx | demo |
infinite scroll | no-lazyload.tsx | demo |
no-lazyload | no-lazyload.tsx | demo |
native | native.tsx | demo |
No vulnerabilities found.
No security vulnerabilities found.