{"id":18023994,"url":"https://github.com/lete114/page-load-progress","last_synced_at":"2025-03-27T00:30:47.023Z","repository":{"id":151838111,"uuid":"624417569","full_name":"Lete114/page-load-progress","owner":"Lete114","description":"Listening to hyperlink loading progress","archived":false,"fork":false,"pushed_at":"2023-06-09T02:32:23.000Z","size":46,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-22T18:11:18.606Z","etag":null,"topics":["hyperlink","listen","load","loader","page","prefetch","preload","progress","progress-bar"],"latest_commit_sha":null,"homepage":"https://lete114.github.io/page-load-progress/test/index.html","language":"JavaScript","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/Lete114.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":"2023-04-06T12:26:44.000Z","updated_at":"2024-04-18T13:35:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"1d273202-81e4-466d-acef-030fb0ebec51","html_url":"https://github.com/Lete114/page-load-progress","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/Lete114%2Fpage-load-progress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lete114%2Fpage-load-progress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lete114%2Fpage-load-progress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lete114%2Fpage-load-progress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Lete114","download_url":"https://codeload.github.com/Lete114/page-load-progress/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245760562,"owners_count":20667886,"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":["hyperlink","listen","load","loader","page","prefetch","preload","progress","progress-bar"],"created_at":"2024-10-30T07:11:37.958Z","updated_at":"2025-03-27T00:30:47.017Z","avatar_url":"https://github.com/Lete114.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Page-Load-Progress\n\nLet traditional ordinary websites have page loading progress when clicking a tag to jump pages\n\n\u003e [preview demo](https://lete114.github.io/page-load-progress/test/index.html)\n\n## Installation\n\nAdd [page-load-progress.js](https://cdn.jsdelivr.net/npm/page-load-progress/page-load-progress.min.js) to your project.\n\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/page-load-progress/page-load-progress.min.js\"\u003e\u003c/script\u003e\n```\n\nOr\n\n```bash\nnpm install page-load-progress\n```\n\n## Basic usage\n\nJust listen to `progress:start` and `progress:end` to control the progress\n\n```js\n// Triggered when the a tag on the page is clicked\ndocument.addEventListener('progress:start', () =\u003e {\n  console.log('start')\n})\n\n// Triggered when the html file for the a tag is loaded\ndocument.addEventListener('progress:end', () =\u003e {\n  console.log('end')\n})\n\n// Triggered when the html file of the a tag is loaded incorrectly\ndocument.addEventListener('progress:error', () =\u003e {\n  console.log('error')\n})\n\n// When you need to filter some links that don't need a progress bar\npageLoadProgress({ ignoreKeywords: ['/logout'] })\n\n// default: 500ms\n// Delay the execution of the page jump when the `progress:end` event is triggered (used to wait for the progress bar to reach 100% animation effect)\npageLoadProgress({ defer: 500 })\n```\n\n## Add progress bar\n\nUse [NProgress.js](https://github.com/rstacruz/nprogress/)\n\n```js\n// Triggered when the a tag on the page is clicked\ndocument.addEventListener('progress:start', () =\u003e {\n  NProgress.start()\n})\n\n// Triggered when the html file for the a tag is loaded\ndocument.addEventListener('progress:end', () =\u003e {\n  NProgress.done()\n})\n```\n\nHere's a simple example of a progress bar\n\n```js\n!(function () {\n  var style = document.createElement('style')\n  style.textContent = `\n    .__progress__ {\n        top: 0; \n        left: 0;\n        position: fixed;\n        width: 10%;\n        height: 2px;\n        z-index: 103;\n        background-color: #e58a8a;\n        transition: width 0.4s ease 0s;\n    }`\n  document.head.appendChild(style)\n\n  var timer = null\n  document.addEventListener('progress:start', () =\u003e {\n    var progress = 10\n    var div = document.createElement('div')\n    div.className = '__progress__'\n    document.body.prepend(div)\n    var max = 10,\n      mini = 3\n    var result = max - mini\n    timer = setInterval(function () {\n      var num = parseInt(Math.random() * result)\n      var randomResult = num + mini\n      progress += randomResult\n      if (progress \u003e 95) progress = 95\n      div.style.width = progress + '%'\n    }, 500)\n  })\n\n  document.addEventListener('progress:end', () =\u003e {\n    clearInterval(timer)\n    var progress = document.querySelector('.__progress__')\n    if (progress) progress.style.width = '100%'\n    setTimeout(() =\u003e {\n      progress.parentElement.removeChild(progress)\n    }, 500)\n  })\n})()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flete114%2Fpage-load-progress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flete114%2Fpage-load-progress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flete114%2Fpage-load-progress/lists"}