{"id":28700402,"url":"https://github.com/joobypm/clusterize-lazy","last_synced_at":"2026-03-09T23:03:19.167Z","repository":{"id":298899489,"uuid":"1001162600","full_name":"JoobyPM/clusterize-lazy","owner":"JoobyPM","description":"⚡️ Virtual-scroll helper for browsers. Renders millions of rows smoothly and lazily fetches only what’s visible. Tiny bundle, zero deps beyond @tanstack/virtual-core, fully typed with TypeScript, works in every modern browser.","archived":false,"fork":false,"pushed_at":"2025-06-22T09:01:44.000Z","size":1986,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-22T01:51:43.717Z","etag":null,"topics":["frontend","infinite-scroll","javascript","lazy-loading","scroll-performance","tanstack-virtual","typescript","vanilla-js","virtual-list","virtual-scroll"],"latest_commit_sha":null,"homepage":"https://joobypm.github.io/clusterize-lazy/examples/quotes.html","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JoobyPM.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2025-06-12T23:35:38.000Z","updated_at":"2025-06-22T08:59:17.000Z","dependencies_parsed_at":"2025-06-13T14:22:40.903Z","dependency_job_id":"3d6e9793-c5df-4f43-9481-f63b0409f2e3","html_url":"https://github.com/JoobyPM/clusterize-lazy","commit_stats":null,"previous_names":["joobypm/clusterize-lazy"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/JoobyPM/clusterize-lazy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoobyPM%2Fclusterize-lazy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoobyPM%2Fclusterize-lazy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoobyPM%2Fclusterize-lazy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoobyPM%2Fclusterize-lazy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JoobyPM","download_url":"https://codeload.github.com/JoobyPM/clusterize-lazy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoobyPM%2Fclusterize-lazy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30315984,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T20:05:46.299Z","status":"ssl_error","status_checked_at":"2026-03-09T19:57:04.425Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["frontend","infinite-scroll","javascript","lazy-loading","scroll-performance","tanstack-virtual","typescript","vanilla-js","virtual-list","virtual-scroll"],"created_at":"2025-06-14T11:07:20.267Z","updated_at":"2026-03-09T23:03:19.135Z","avatar_url":"https://github.com/JoobyPM.png","language":"TypeScript","readme":"# Clusterize-Lazy\n\nVanilla-JS virtual list with lazy loading and initial skeletons.\n\n\u003cspan id=\"size-badge\"\u003e![gzip](https://img.shields.io/bundlejs/size/clusterize-lazy)\u003c/span\u003e ![MIT](https://img.shields.io/github/license/JoobyPM/clusterize-lazy)\n\n`Clusterize-Lazy` lets you render **millions of rows** in a scrollable\ncontainer while downloading data only for what the user can actually\nsee. Its goal is an **easy, framework-agnostic** API that just works in\nany modern browser - no build step required.\n\n\u003e Small footprint, great DX - powered by [@tanstack/virtual-core](https://github.com/TanStack/virtual)\n\n\u003cdiv align=\"center\"\u003e\u003cimg src=\"docs/assets/demo.gif\" width=\"600\" alt=\"demo\"/\u003e\u003c/div\u003e\n\n## Features\n\n- **Single dependency** - relies on the rock-solid engine\\\n  `@tanstack/virtual-core` (thanks Tanner \u0026 the TanStack team!)\n- **Dynamic row height** - actual DOM sizes are measured automatically\n- **Lazy loading + skeletons** - smooth UX even on shaky connections\n- **Typed from the ground up** - shipped `.d.ts` works in ESM browsers and legacy browsers (with polyfills)\n- **Batteries included** - debug logging, auto cache eviction, progress callback\n\n## Live demo\n\nTest it instantly (no transpiler):\\\n\u003chttps://joobypm.github.io/clusterize-lazy/examples/quotes.html\u003e\n\n\u003e Source lives in `docs/examples/`\n\n## Installation\n\n### pnpm / npm / Yarn\n\n```bash\npnpm add clusterize-lazy\n```\n\n```js\nimport Clusterize from 'clusterize-lazy';\nconst cluster = Clusterize({...});\n```\n\n### `\u003cscript\u003e` tag (UMD)\n\n```html\n\u003cscript src=\"https://unpkg.com/clusterize-lazy/dist/index.iife.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  const cluster = Clusterize.default({...});\n\u003c/script\u003e\n```\n\n## 30-second example\n\n```html\n\u003cdiv id=\"scroll\" style=\"height: 320px; overflow: auto\"\u003e\n\t\u003cdiv id=\"content\"\u003e\u003c/div\u003e\n\u003c/div\u003e\n\n\u003cscript type=\"module\"\u003e\n\timport Clusterize from '/dist/index.esm.js';\n\n\tfunction fetchRows(offset, size = 40) {\n\t\treturn fetch(`/api/items?skip=${offset}\u0026limit=${size}`).then((r) =\u003e r.json());\n\t}\n\n\tconst cluster = Clusterize({\n\t\trowHeight: 32,\n\t\tscrollElem: document.getElementById('scroll'),\n\t\tcontentElem: document.getElementById('content'),\n\n\t\tfetchOnInit: async () =\u003e {\n\t\t\tconst rows = await fetchRows(0);\n\t\t\treturn { totalRows: 50_000, rows };\n\t\t},\n\t\tfetchOnScroll: fetchRows,\n\t\trenderSkeletonRow: (h, i) =\u003e `\u003cdiv class=\"skeleton\" style=\"height:${h}px\"\u003e\u003c/div\u003e`,\n\t\trenderRaw: (i, row) =\u003e `\u003cdiv\u003e${i + 1}. ${row.title}\u003c/div\u003e`,\n\t});\n\u003c/script\u003e\n```\n\n## Mutation example\n\n```js\n// Enable mutations with buildIndex\nconst cluster = Clusterize({\n\trowHeight: 40,\n\tbuildIndex: true,        // Enable ID-based operations\n\tprimaryKey: 'id',        // Use 'id' field as primary key\n\tscrollElem: document.getElementById('scroll'),\n\tcontentElem: document.getElementById('content'),\n\t\n\tfetchOnInit: () =\u003e Promise.resolve([\n\t\t{ id: 1, name: 'Alice', status: 'active' },\n\t\t{ id: 2, name: 'Bob', status: 'inactive' },\n\t\t{ id: 3, name: 'Charlie', status: 'active' }\n\t]),\n\tfetchOnScroll: () =\u003e Promise.resolve([]),\n\trenderSkeletonRow: (h) =\u003e `\u003cdiv style=\"height:${h}px\"\u003eLoading...\u003c/div\u003e`,\n\trenderRaw: (i, row) =\u003e `\u003cdiv\u003e${row.name} (${row.status})\u003c/div\u003e`\n});\n\n// Add new rows\ncluster.insert([{ id: 4, name: 'David', status: 'active' }], 1);\n\n// Update existing row by ID\ncluster.update([{ id: 2, data: { id: 2, name: 'Bob', status: 'active' } }]);\n\n// Remove rows by ID\ncluster.remove([1, 3]);\n```\n\n## Quick reference\n\n| Option / method                   | Type / default                               | Purpose                                        |\n| --------------------------------- | -------------------------------------------- | ---------------------------------------------- |\n| **required**                      |                                              |                                                |\n| `rowHeight`                       | `number`                                     | Fixed row estimate (px)                        |\n| `fetchOnInit()`                   | `() ⇒ Promise\u003cRow[] \\| { totalRows, rows }\u003e` | First data batch _or_ rows + total count       |\n| `fetchOnScroll(offset)`           | `(number) ⇒ Promise\u003cRow[]\u003e`                  | Fetches when a gap becomes visible             |\n| `renderSkeletonRow(height,index)` | `(number,number) ⇒ string`                   | Placeholder HTML                               |\n| **optional**                      |                                              |                                                |\n| `renderRaw(index,data)`           | `(number,Row) ⇒ string` · `undefined`        | Row renderer for object data                   |\n| `buffer`                          | `5`                                          | Rows rendered above/under viewport             |\n| `prefetchRows`                    | `buffer`                                     | Rows fetched ahead of viewport                 |\n| `debounceMs`                      | `120`                                        | Debounce between scroll \u0026 fetch                |\n| `cacheTTL`                        | `300 000`                                    | Milliseconds before a cached row is stale      |\n| `autoEvict`                       | `false`                                      | Drop stale rows automatically                  |\n| `showInitSkeletons`               | `true`                                       | Paint skeletons immediately before first fetch |\n| `debug`                           | `false`                                      | Console debug output                           |\n| `scrollingProgress(cb)`           | `(firstVisible:number) ⇒ void`               | Fires on every render                          |\n| `buildIndex`                      | `false`                                      | Build ID-to-index map for mutations           |\n| `primaryKey`                      | `'id'`                                       | Property name for primary key                  |\n| **methods**                       |                                              |                                                |\n| `refresh()`                       | `void`                                       | Force re-render                                |\n| `scrollToRow(idx, smooth?)`       | `void` ( `true` = smooth)                    | Programmatic scroll                            |\n| `getLoadedCount()`                | `number`                                     | How many rows are cached                       |\n| `destroy()`                       | `void`                                       | Tear down listeners \u0026 cache                    |\n| `insert(rows, at?)`               | `void`                                       | Insert rows at position (default: 0)          |\n| `update(patches)`                 | `void`                                       | Update rows by ID or index                     |\n| `remove(keys)`                    | `void`                                       | Remove rows by ID or index                     |\n| `_dump()`                         | `{ cache, index }`                           | Debug helper for internal state               |\n\n\u003e See [docs/API.md](docs/API.md) for the full contract.\n\n## Contributing\n\n```bash\ngit clone https://github.com/JoobyPM/clusterize-lazy.git\npnpm i\npnpm test      # vitest + jsdom\npnpm build     # tsup + esbuild\n```\n\nFormatting \u0026 linting are handled by **Deno** (`deno fmt`, `deno lint`).\nPlease follow Conventional Commits; releases are automated.\n\n## Acknowledgements\n\n_Huge shout-out to_ **\\[@tanstack/virtual-core]** - Clusterize-Lazy is\nbasically a thin, opinionated shell around this fantastic engine.\nIf you need a React / Vue / Solid binding or more power, use the TanStack\npackage directly and consider sponsoring the project.\n\n## License\n\nMIT © 2025 JoobyPM\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoobypm%2Fclusterize-lazy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoobypm%2Fclusterize-lazy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoobypm%2Fclusterize-lazy/lists"}