{"id":21967066,"url":"https://github.com/barretlee/lazyload","last_synced_at":"2025-04-24T05:11:10.170Z","repository":{"id":146465030,"uuid":"46271570","full_name":"barretlee/lazyload","owner":"barretlee","description":"Lazyload images or lazy execute scripts. （图片脚本懒加载）","archived":false,"fork":false,"pushed_at":"2016-07-05T02:01:17.000Z","size":14,"stargazers_count":88,"open_issues_count":2,"forks_count":34,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-30T07:11:18.174Z","etag":null,"topics":["javascript","lazyload","lazyload-images","lazyload-script"],"latest_commit_sha":null,"homepage":"https://barretlee.github.io/lazyload/demo/index.html","language":"HTML","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/barretlee.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2015-11-16T11:50:49.000Z","updated_at":"2025-02-17T05:42:53.000Z","dependencies_parsed_at":"2023-07-17T16:32:48.513Z","dependency_job_id":null,"html_url":"https://github.com/barretlee/lazyload","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barretlee%2Flazyload","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barretlee%2Flazyload/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barretlee%2Flazyload/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barretlee%2Flazyload/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/barretlee","download_url":"https://codeload.github.com/barretlee/lazyload/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250566509,"owners_count":21451232,"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":["javascript","lazyload","lazyload-images","lazyload-script"],"created_at":"2024-11-29T13:20:26.730Z","updated_at":"2025-04-24T05:11:10.163Z","avatar_url":"https://github.com/barretlee.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Lazyload\n\nA mini lazyload component within 100 lines code, support amd/cmd require.\n\n文章导读 in Chinese: \u003chttp://www.barretlee.com/blog/2015/11/16/lazyload-component/\u003e\n\nLive Demo: \u003chttp://barretlee.github.io/lazyload/demo/index.html\u003e\n\n### Usage\n\nInclude the lazyload scirpt to your html:\n\n```html\n\u003cscript src=\"https://raw.githubusercontent.com/barretlee/lazyload/master/index.js\"\u003e\u003c/script\u003e\n\n\u003cdiv class=\"box\"\u003e\n  \u003cdiv class=\"item\"\u003e\u003cimg src data-src=\"img-path\"\u003e\u003c/div\u003e\n  \u003cdiv class=\"item\"\u003e\u003ctextarea\u003ealert(1)\u003c/textarea\u003e\u003c/div\u003e\n\u003c/div\u003e\n```\n\nIt exports an api to global:\n\n```js\nnew Lazyload('.box .item', {\n  callback: function(){\n    console.log(\"All item loaded\");\n  }\n});\n```\n\n### Params \n\nThere are two param your can set when get an Lazyload instance:\n\n```js\nnew Lazyload('.item', {\n  tag: \"data-src\",\n  distance: 0,\n  callback: function(){\n    // ...\n  }\n});\n```\n\n- `tag`, default is 'data-src', we set the lazyload image 'src' to null, then read 'data-src' attribute;\n- `distance`, default is 0, if you want to show the lazyload element in advance, you can set it to a positive number;\n- `callback`, when all item loaded, it will trigger.\n\nAlso, two more api:\n\n```js\nvar lazyload = new Lazyload();\nlazyload.pause();\nsetTimeout(function(){\n  lazyload.restart();\n});\n```\n\n- `.pause()`, pause the lazyload use the inner variable `_pause`;\n- `.resetart()`, set `_pause` false;\n\n\n### Liscese\n\nUnder MIT Liscese. Copyright (c) 2015 小胡子哥(Barret Lee)\n\n### changelog\n\n- 2015-11-20\n  * add `callback` function\n  * add `pause` and `restart` function\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarretlee%2Flazyload","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbarretlee%2Flazyload","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarretlee%2Flazyload/lists"}