{"id":37902383,"url":"https://github.com/loadingio/ldlazy","last_synced_at":"2026-01-16T17:05:36.944Z","repository":{"id":42994086,"uuid":"198856526","full_name":"loadingio/ldlazy","owner":"loadingio","description":"Vanilla JS Lazy Show Library","archived":false,"fork":false,"pushed_at":"2023-06-13T13:48:04.000Z","size":2007,"stargazers_count":3,"open_issues_count":5,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-05T01:23:29.586Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/loadingio.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}},"created_at":"2019-07-25T15:25:38.000Z","updated_at":"2024-05-11T08:42:45.000Z","dependencies_parsed_at":"2023-01-29T03:45:22.347Z","dependency_job_id":null,"html_url":"https://github.com/loadingio/ldlazy","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/loadingio/ldlazy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loadingio%2Fldlazy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loadingio%2Fldlazy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loadingio%2Fldlazy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loadingio%2Fldlazy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loadingio","download_url":"https://codeload.github.com/loadingio/ldlazy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loadingio%2Fldlazy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28480081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: 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":[],"created_at":"2026-01-16T17:05:36.376Z","updated_at":"2026-01-16T17:05:36.930Z","avatar_url":"https://github.com/loadingio.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ldlazy\n\nVanilla JS Lazy Show Library\n\n\n## Usage\n\ninstall via npm:\n\n    npm install ldlazy\n\n\ninclude the required files:\n\n    \u003clink rel=\"stylesheet\" type=\"text/css\" href=\"path-to-dist/index.min.css\"\u003e\n    \u003cscript type=\"text/javascript\" src=\"path-to-dist/index.min.js\"\u003e\u003c/script\u003e\n\n\nconstruct a ldlazy object:\n\n    ldlz = new ldlazy({root: document.body,  toggle: function(n) { ... } });\n    ldlz.add( ... );\n\n\n## Constructor Options\n\n - `root` - root element for monitoring scroll.\n - `toggle` - when visibility changes, toggle will be called with the target node as param. default null.\n - `debounce` - millisecond delay before handling events. require debounce.js, otherwise will be ignored.\n\n\n## API\n\n - `ldlz.add(n)` - start monitoring node n for visibility change.\n - `ldlz.remove(n)` - stop monitoring node n for visibility change.\n\n\n## Pug Mixin\n\nTo make it easier to add an ldlazy image tag, we offer a pug mixin with a minimized gif placeholder, which can be used as:\n\n    include path-to-dist/index.pug\n    +ldlz(\"your-file\")( ...attributes... )\n\n\nAn example with `@plotdb/srcbuild`:\n\n    include @/ldlazy/dist/index.pug\n    +ldlz(\"thumbnail.png\").custom-cls(width=\"800px\",height=\"600px\",alt=\"thumbnail\")\n\nwhich generates following html:\n\n    \u003cimg class=\"ldlz clustom-cls\" src=\"data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=\" data-src=\"thumbnail.png\" width=\"800px\" height=\"600px\" alt=\"thumbnail\"\u003e\n\n\n## How It Works\n\nldlazy controls the visibility of an element based on the event from IntersectionObserver. Two styles will be touched:\n\n - `visibility`\n - `opacity`\n\nAlternatively, you can specify a source url for showing / lazy loading an image when the element becomes visible. Use `src` or `data-src` (for lazy loading ) attributes to indicate image url:\n\n    \u003cdiv src=\"\"\u003e\u003c/div\u003e\n    \u003cimg data-src=\"...\"\u003e\n\nldlazy fill the corresponding field ( `style.backgroundImage` for `div`, `src` for `img` ) when the element is visible.\n\nAdditionally, specify following css class over an element for additional effect:\n\n - `nocache`: always load this image with a randomized querystring, which forcily disable the cache.\n   - useful for transitional animated SVG \n - `placeholder`: insert a invisible placeholder image with given URL inside this node.\n   - the image may be loaded before visible, so it becomes lazy show instead of lazy load.\n   - only applicable for container type node ( such as div ).\n\n\n## Class API\n\n - `init()`: ask `ldlazy` to scan and init all elements with `ldlz` classes.\n\n\n## Best Practice\n\nWhen using with `img` tag, you may want to fill following attributes to prevent [CLS - Cumulative Layout Shift](https://web.dev/cls/):\n\n - `width` and `height`: set to the expected size of your image.\n   - this will be overwritten if you also specify values in stylesheet, but it helps in keeping aspect ratio.\n - `src`: you can still fill `src` attribute with a 66 bytes long, single pixel, transprent gif:\n   - `data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEAAAAALAAAAAABAAEAAAIA`\n   - this is available as a mixin named `ldlz` in Pug after including `dist/index.pug`, with `src` as only parameter:\n\n    +ldlz(\"path-to-your-image\")(additional-attribute=\"here\", ...)\n\n\n## Placeholder Image\n\nPlaceholder image prefilled in `src` attribute can prevent a broken image or `alt` attribute to be shown. While we may prefer transparent placeholder image, ldlazy actually make elements transparent before revealing them so we actually don't need a real transpareny pixels.\n\nHere are some possible smallest images, with their corresponding sources:\n\nsmallest 1px gif (26bytes/58bytes, currently used), may be shown as black in some browsers (e.g., IE11):\n\n    data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=\n\n\nsmallest transparent 1px gif (33bytes/66bytes):\n\n    data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEAAAAALAAAAAABAAEAAAIA\n\nalternative with SVG (41bytes/60bytes)\n\n    data:image/svg+xml,\u003csvg xmlns=\"http://www.w3.org/2000/svg\"/\u003e\n\n\ncheck following pages for more resources about a minimal image:\n\n - 26 bytes one:\n   - https://github.com/mathiasbynens/small\n   - https://stackoverflow.com/questions/6018611/smallest-data-uri-image-possible-for-a-transparent-image\n   - http://probablyprogramming.com/2009/03/15/the-tiniest-gif-ever\n - 33 bytes one:\n   - https://stackoverflow.com/questions/2570633/smallest-filesize-for-transparent-single-pixel-image\n\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floadingio%2Fldlazy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floadingio%2Fldlazy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floadingio%2Fldlazy/lists"}