Skip to content

Commit 6f6a411

Browse files
committed
chore: updates package keywords
1 parent 4e17baa commit 6f6a411

File tree

3 files changed

+30
-35
lines changed

3 files changed

+30
-35
lines changed

README.md

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66

77
> Lightweight utility for dynamically loading external scripts into the browser — framework-agnostic, caching-safe, and CSP-friendly.
88
9+
## ✅ Features
10+
11+
- 📆 Small and framework-agnostic
12+
- 📑 Fully typed with TypeScript for autocompletion and safety
13+
- 🚫 Prevents duplicate script injection via internal cache
14+
915
## 📦 Installation
1016

1117
```bash
@@ -40,44 +46,12 @@ Loads an external script dynamically and returns a `Promise<HTMLScriptElement>`.
4046
| `options` | `LoadScriptOptions` | `loadScript` options (e.g. `async`, `type`) |
4147
| `container` | `HTMLElement` | HTML element to append `<script />` to (default: `document.head`) |
4248

43-
## ✅ Features
44-
45-
- 📑 Fully typed with TypeScript for autocompletion and safety
46-
- 🚫 Prevents duplicate script injection via internal cache
47-
- ⚙️ Supports `data-*`, `nonce`, `fetchPriority`, `crossOrigin`, and other modern attributes
48-
- 📆 Small and framework-agnostic
49-
- 🔒 CSP-friendly via `nonce` support
50-
51-
---
52-
53-
## 🧪 Example: With SolidJS
54-
55-
```ts
56-
import { onMount } from "solid-js";
57-
import { loadScript } from "@dschz/load-script";
58-
59-
const WidgetLoader = () => {
60-
let containerRef!: HTMLElement;
61-
62-
onMount(async () => {
63-
await loadScript("https://example.com/widget.js", {
64-
type: "text/javascript",
65-
async: true,
66-
}, containerRef);
67-
});
68-
69-
return <div ref={containerRef} />;
70-
};
71-
```
72-
7349
## 📝 Notes
7450

75-
- Scripts are cached by `src` unless `innerHTML` or `textContent` is used
51+
- Scripts are cached by `src`. If `innerHTML` or `textContent` is set, the script will not be cached.
7652
- A nil (`undefined`/`null`) container value will append the script to `document.head`.
7753
- Cleanup is not automatic — script elements remain in the DOM
7854

79-
---
80-
8155
## 💬 Feedback & Contributions
8256

8357
Feel free to open [issues](https://github.com/dsnchz/load-script/issues) or submit pull requests. PRs are welcome!

package.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,27 @@
1515
"publishConfig": {
1616
"access": "public"
1717
},
18+
"keywords": [
19+
"async",
20+
"async-script",
21+
"script",
22+
"script-loader",
23+
"script-injector",
24+
"script-loader",
25+
"inject",
26+
"inject-script",
27+
"load",
28+
"loader",
29+
"load-script",
30+
"dynamic-script",
31+
"external-script",
32+
"html-script",
33+
"browser",
34+
"javascript",
35+
"typescript",
36+
"utility",
37+
"promise"
38+
],
1839
"main": "./dist/index.js",
1940
"module": "./dist/index.js",
2041
"types": "./dist/index.d.ts",

src/loadScript.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ export const loadScript = async (
102102
referrerPolicy,
103103
integrity,
104104
nonce,
105-
onLoad = () => {},
106-
onError = () => {},
105+
onLoad,
106+
onError,
107107
...attributes
108108
} = options;
109109

0 commit comments

Comments
 (0)