{"id":19683757,"url":"https://github.com/fngr2911/loady","last_synced_at":"2025-06-11T23:02:27.628Z","repository":{"id":42869664,"uuid":"258474935","full_name":"FNGR2911/loady","owner":"FNGR2911","description":"Load scripts after an event like a click on a button","archived":false,"fork":false,"pushed_at":"2023-01-06T04:20:53.000Z","size":918,"stargazers_count":1,"open_issues_count":10,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-19T17:21:44.071Z","etag":null,"topics":["consent-management","events","javascript","load","third-party-libraries"],"latest_commit_sha":null,"homepage":null,"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/FNGR2911.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}},"created_at":"2020-04-24T10:03:13.000Z","updated_at":"2022-06-05T09:55:03.000Z","dependencies_parsed_at":"2023-02-05T07:00:40.624Z","dependency_job_id":null,"html_url":"https://github.com/FNGR2911/loady","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/FNGR2911/loady","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FNGR2911%2Floady","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FNGR2911%2Floady/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FNGR2911%2Floady/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FNGR2911%2Floady/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FNGR2911","download_url":"https://codeload.github.com/FNGR2911/loady/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FNGR2911%2Floady/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259360728,"owners_count":22845817,"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":["consent-management","events","javascript","load","third-party-libraries"],"created_at":"2024-11-11T18:15:27.082Z","updated_at":"2025-06-11T23:02:27.361Z","avatar_url":"https://github.com/FNGR2911.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# loady\n\n**loady** is a tiny and lightweight (1.4kb gzipped) library that loads scripts after a selected event\nwas triggered – for example a click on a button. If the consent is already given, the script will be loaded immediately.\n\n[![npm version](https://badge.fury.io/js/%40fngr%2Floady.svg)](https://badge.fury.io/js/%40fngr%2Floady)\n[![dependencies](https://david-dm.org/fngr2911/loady.svg)](https://david-dm.org/fngr2911/loady)\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)\n[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat-square)](https://github.com/fngr2911/loady/issues)\n\n### Installation\n\nInstall via npm\n\n```bash\n$ npm i @fngr/loady\n```\n\n### Usage\n\n```javascript\nimport loady from '@fngr/loady'\n\nloady({\n  triggerElement: document.getElementById('myButton'),\n  event: 'click',\n  storageItem: 'load-chartjs-consent',\n  script: 'https://cdn.jsdelivr.net/npm/chart.js@2.8.0',\n  attributes: {\n    defer: true,\n  },\n})\n```\n\n### Options\n\n`triggerElement`: _DOM Element_, required  \nThe DOM Element where the event listener will be added to.\n\n`event`: _String_, required, default: 'click'  \nString of event type that triggers event listener on triggerElement\n\n`storageItem`: _String_, required  \nKey of the item that will be placed in localStorage to determine consent\n\n`script`: _String_, required  \nThe URL of the script to be loaded after consent\n\n`attributes`: _Object_, optional  \nObject of attributes that should be added to script tag. Something like `{ 'defer': true }`\n\n### License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffngr2911%2Floady","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffngr2911%2Floady","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffngr2911%2Floady/lists"}