{"id":22979408,"url":"https://github.com/jsdeveloperr/react-lazy-loader-component","last_synced_at":"2025-03-21T15:33:17.112Z","repository":{"id":64207073,"uuid":"573927253","full_name":"jsdeveloperr/react-lazy-loader-component","owner":"jsdeveloperr","description":"Fast 1.15KB, Gzip 0.63KB, React Component to lazy load and other components/elements and use the Intersection Observer API.","archived":false,"fork":false,"pushed_at":"2023-10-07T10:16:57.000Z","size":1116,"stargazers_count":2,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-26T11:04:25.347Z","etag":null,"topics":["lazy-loading","react","react-lazy-load","react-lazy-load-component","react-lazy-loader-component","react-lazy-loading","react-lazyload"],"latest_commit_sha":null,"homepage":"https://codesandbox.io/p/sandbox/react-lazy-loader-component-m5mkpv","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jsdeveloperr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-03T21:46:00.000Z","updated_at":"2025-01-07T14:02:37.000Z","dependencies_parsed_at":"2024-12-15T01:31:19.397Z","dependency_job_id":"b716246c-e50e-42e7-a0fe-1f7ce812cb05","html_url":"https://github.com/jsdeveloperr/react-lazy-loader-component","commit_stats":{"total_commits":19,"total_committers":1,"mean_commits":19.0,"dds":0.0,"last_synced_commit":"89fc67d89187da055d2cdd805c11ed03845eb195"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsdeveloperr%2Freact-lazy-loader-component","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsdeveloperr%2Freact-lazy-loader-component/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsdeveloperr%2Freact-lazy-loader-component/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsdeveloperr%2Freact-lazy-loader-component/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsdeveloperr","download_url":"https://codeload.github.com/jsdeveloperr/react-lazy-loader-component/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244822791,"owners_count":20516169,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lazy-loading","react","react-lazy-load","react-lazy-load-component","react-lazy-loader-component","react-lazy-loading","react-lazyload"],"created_at":"2024-12-15T01:30:44.640Z","updated_at":"2025-03-21T15:33:17.078Z","avatar_url":"https://github.com/jsdeveloperr.png","language":"TypeScript","readme":"\u003ca name=\"read-me-template\" /\u003e\n\n\u003ch1 align=\"center\"\u003e\n  \u003cbr\u003e\n    \u003cimg src=\"https://github.com/jsdeveloperr/react-lazy-loader-component/blob/master/example/public/assets/logo-lazy.gif\" alt=\"logo\" width=\"300\"\u003e\n  \u003cbr\u003e\u003cbr\u003e\n  🔥 React Lazy Loader Component 🔥\n  \u003cbr\u003e\n  \u003cbr\u003e\n\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![npm](https://img.shields.io/npm/v/react-lazy-loader-component?style=flat-square)](https://www.npmjs.com/package/react-lazy-loader-component)\n![npm bundle size](https://img.shields.io/bundlephobia/minzip/react-lazy-loader-component?style=flat-square)\n![npm](https://img.shields.io/npm/dt/react-lazy-loader-component?style=flat-square)\n![GitHub license](https://img.shields.io/npm/l/react-lazy-loader-component?style=flat-square)\n\n\u003c/div\u003e\n\n### :books: Introduction\n\nFast 1.15KB, Gzip 0.63KB, React Component to lazy load and other components/elements and use the [Intersection Observer API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API).\n\n### :rocket: Example\n\nCheck our 👉 [example](https://codesandbox.io/p/sandbox/react-lazy-loader-component-m5mkpv)\n\n### :package: Installation\n\n```bash\n# install with npm\nnpm install react-lazy-loader-component\n# install with yarn\nyarn add react-lazy-loader-component\n# install with pnpm\npnpm add react-lazy-loader-component\n```\n\n### :rocket: Example Repo\n\n- [In Repo](https://github.com/jsdeveloperr/react-lazy-loader-component/blob/master/example)\n\n### 📦 Examples\n\n#### 🗂 Basic Usage\n\n```tsx\nimport React from \"react\";\nimport { LazyLoad } from \"react-lazy-loader-component\";\n\nconst MyComponent = () =\u003e (\n  \u003cLazyLoad\u003e\n    \u003cimg src=\"https://images.pexels.com/photos/3748221/pexels-photo-3748221.jpeg?auto=compress\u0026cs=tinysrgb\u0026w=1260\u0026h=750\u0026dpr=1\" /\u003e\n  \u003c/LazyLoad\u003e\n);\n```\n\n#### 🗂 Loading the image 100px prior to scroll\n\n```tsx\nimport { LazyLoad } from \"react-lazy-loader-component\";\n\nconst MyComponent = () =\u003e (\n  \u003cLazyLoad rootMargin={100}\u003e\n    \u003cimg src=\"https://images.pexels.com/photos/3748221/pexels-photo-3748221.jpeg?auto=compress\u0026cs=tinysrgb\u0026w=1260\u0026h=750\u0026dpr=1\" /\u003e\n  \u003c/LazyLoad\u003e\n);\n```\n\n#### 🗂 Loading image only when 15% of it is in the viewport.\n\n```tsx\nimport { LazyLoad } from \"react-lazy-loader-component\";\n\nconst MyComponent = () =\u003e (\n  \u003cLazyLoad rootMargin={100} threshold={0.95}\u003e\n    \u003cimg src=\"https://images.pexels.com/photos/3748221/pexels-photo-3748221.jpeg?auto=compress\u0026cs=tinysrgb\u0026w=1260\u0026h=750\u0026dpr=1\" /\u003e\n  \u003c/LazyLoad\u003e\n);\n```\n\n#### 🗂 Performing a side effect once your image is loaded\n\n```tsx\nimport { LazyLoad } from \"react-lazy-loader-component\";\n\nconst MyComponent = () =\u003e (\n  \u003cLazyLoad rootMargin={400} threshold={0.95} freezeOnceVisible={true}\u003e\n    \u003cimg src=\"https://images.pexels.com/photos/3748221/pexels-photo-3748221.jpeg?auto=compress\u0026cs=tinysrgb\u0026w=1260\u0026h=750\u0026dpr=1\" /\u003e\n  \u003c/LazyLoad\u003e\n);\n```\n\n#### 🗂 Suspense and Lazy import\n\n```tsx\nimport React, { Suspense } from \"react\";\nimport { LazyLoad } from \"react-lazy-loader-component\";\n\nconst MyComponent = () =\u003e (\n  \u003cSuspense fallback={\u003cdiv\u003eLoading...\u003c/div\u003e}\u003e\n    \u003cLazyLoad rootMargin={100}\u003e\n      \u003cimg src=\"https://images.pexels.com/photos/3748221/pexels-photo-3748221.jpeg?auto=compress\u0026cs=tinysrgb\u0026w=1260\u0026h=750\u0026dpr=1\" /\u003e\n    \u003c/LazyLoad\u003e\n  \u003c/Suspense\u003e\n);\n```\n\n#### 🎉 Props\n\n##### ✏️ tag\n\nType: `ComponentType | keyof JSX.IntrinsicElements` Default: `div`\n\nThe `tag` option allows you to set the html element's tag even when it has no content.\n\n##### ✏️ rootMargin\n\nType: `String` Default: `0%`\n\nThe `rootMargin` option allows you to specify how far below, above, to the left, and to the right of the viewport you want to _begin_ displaying your content. If you specify `0`, your content will be displayed as soon as it is visible in the viewport, if you want to load _100px_ below or above the viewport, use `100`.\n\n##### ✏️ threshold\n\nType: `number | number[]` Default: `0`\n\nThis `threshold` option allows you to specify how much of the element must be shown on the screen prior to loading. This requires a _width_ and _height_ to be set on the `\u003cLazyLoad\u003e` component in order for the browser to calcualte the viewable area.\n\n##### ✏️ className\n\nType: `String`\n\nThe `className` option allows you to set the element's className even when it has no content.\n\n##### ✏️ style\n\nType: `CSSProperties`\n\nThe `style` option allows you to set the element's style even when it has no content.\n\n##### ✏️ freezeOnceVisible\n\nType `Boolean`\n\nA Boolean to execute when the content appears on the screen.\n\n#### 🔥 Building LazyLoad\n\n```\npnpm build\n```\n\n#### 🌈 Running examples\n\n```\ncd example\npnpm dev\n```\n\n#### 📄 License\n\n\u003cdiv calign=\"center\"\u003e\n    🍁 MIT Licensed | Copyright © 2022-present Abdulnasır Olcan and @ReactLazyLoadComponent contributors\n\u003c/div\u003e\n\n---\n\n[Back To The Top](#read-me-template)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsdeveloperr%2Freact-lazy-loader-component","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsdeveloperr%2Freact-lazy-loader-component","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsdeveloperr%2Freact-lazy-loader-component/lists"}