{"id":31940330,"url":"https://github.com/dsnchz/load-script","last_synced_at":"2025-10-14T08:53:27.761Z","repository":{"id":292383181,"uuid":"980696821","full_name":"dsnchz/load-script","owner":"dsnchz","description":"Dynamically load scripts in the browser with caching.","archived":false,"fork":false,"pushed_at":"2025-06-05T16:34:46.000Z","size":102,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-28T21:18:37.880Z","etag":null,"topics":["load-script","script","script-loader","solidjs","ssr"],"latest_commit_sha":null,"homepage":"","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/dsnchz.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":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-09T14:58:06.000Z","updated_at":"2025-06-11T13:46:35.000Z","dependencies_parsed_at":"2025-05-09T17:36:14.409Z","dependency_job_id":null,"html_url":"https://github.com/dsnchz/load-script","commit_stats":null,"previous_names":["dsnchz/load-script"],"tags_count":0,"template":false,"template_full_name":"thedanchez/template-solidjs-library","purl":"pkg:github/dsnchz/load-script","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsnchz%2Fload-script","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsnchz%2Fload-script/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsnchz%2Fload-script/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsnchz%2Fload-script/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dsnchz","download_url":"https://codeload.github.com/dsnchz/load-script/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsnchz%2Fload-script/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279018312,"owners_count":26086348,"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","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["load-script","script","script-loader","solidjs","ssr"],"created_at":"2025-10-14T08:52:56.053Z","updated_at":"2025-10-14T08:53:27.755Z","avatar_url":"https://github.com/dsnchz.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @dschz/load-script\n\n[![License](https://img.shields.io/badge/license-MIT-green)](LICENSE)\n[![npm version](https://img.shields.io/npm/v/@dschz/load-script?color=blue)](https://www.npmjs.com/package/@dschz/load-script)\n[![Bundle Size](https://img.shields.io/bundlephobia/minzip/@dschz/load-script)](https://bundlephobia.com/package/@dschz/load-script)\n[![JSR](https://jsr.io/badges/@dschz/load-script/score)](https://jsr.io/@dschz/load-script)\n[![CI](https://github.com/dsnchz/load-script/actions/workflows/ci.yaml/badge.svg)](https://github.com/dsnchz/load-script/actions/workflows/ci.yaml)\n\n\u003e A lightweight utility for safely loading external scripts in the browser. Fully typed, SSR-aware, framework-agnostic, and caching-safe — ideal for modern web apps and libraries.\n\n## ✅ Features\n\n- 📆 Small and framework-agnostic\n- 📑 Fully typed with TypeScript for autocompletion and safety\n- 🚫 Prevents duplicate script injection via internal cache\n- 🛡️ Safe to import and use in SSR and non-browser environments\n\n## 📦 Installation\n\n```bash\nnpm install @dschz/load-script\npnpm install @dschz/load-script\nyarn install @dschz/load-script\nbun install @dschz/load-script\n```\n\n## 🔧 Usage\n\n```ts\nimport { loadScript } from \"@dschz/load-script\";\n\nawait loadScript(\"https://example.com/library.js\", {\n  async: true,\n  type: \"text/javascript\",\n});\n```\n\n## 🧠 API\n\n### `loadScript(src, options?, container?)`\n\nLoads an external script dynamically and returns a `Promise\u003cHTMLScriptElement\u003e`.\n\n#### Parameters:\n\n| Name        | Type                | Description                                                       |\n| ----------- | ------------------- | ----------------------------------------------------------------- |\n| `src`       | `string`            | Script URL (required)                                             |\n| `options`   | `LoadScriptOptions` | `loadScript` options (e.g. `async`, `type`)                       |\n| `container` | `HTMLElement`       | HTML element to append `\u003cscript /\u003e` to (default: `document.head`) |\n\n## 📝 Notes\n\n- Scripts are cached by `src`. If `innerHTML` or `textContent` is set, the script will not be cached.\n- A nil (`undefined`/`null`) container value will append the script to `document.head`.\n- Cleanup is not automatic — script elements remain in the DOM\n- ❄️ SSR-safe: The function will reject gracefully when called in server environments without crashing. No DOM APIs are accessed until the environment is confirmed to be browser-based.\n\n## 💬 Feedback \u0026 Contributions\n\nFeel free to open [issues](https://github.com/dsnchz/load-script/issues) or submit pull requests. PRs are welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdsnchz%2Fload-script","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdsnchz%2Fload-script","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdsnchz%2Fload-script/lists"}