|
1 | 1 | # @dschz/load-script
|
2 | 2 |
|
| 3 | +## 1.0.8 |
| 4 | + |
| 5 | +### Patch Changes |
| 6 | + |
| 7 | +- updates readme badges |
| 8 | + |
3 | 9 | ## 1.0.7
|
4 | 10 |
|
5 | 11 | ### Patch Changes
|
|
10 | 16 |
|
11 | 17 | ### Patch Changes
|
12 | 18 |
|
13 |
| -- make loadScript SSR safe with isBrowser guard to ensure function only runs in browser environments. |
| 19 | +- **🛡️ SSR Safety**: Safe to import and use in server-side rendering and non-browser environments with graceful error handling |
14 | 20 |
|
15 | 21 | ## 1.0.5
|
16 | 22 |
|
|
44 | 50 |
|
45 | 51 | ## 1.0.0
|
46 | 52 |
|
47 |
| -### Major Changes |
| 53 | +**Initial Release**: Complete utility function for dynamically loading external scripts into the browser with advanced features and safety guarantees. |
| 54 | + |
| 55 | +### Features |
| 56 | + |
| 57 | +- **🔄 Smart Caching**: Prevents duplicate script injection via intelligent in-memory caching by script `src` URL |
| 58 | +- **⚡ Framework Agnostic**: Works with any JavaScript framework or vanilla JS applications |
| 59 | +- **📝 Full TypeScript Support**: Comprehensive type definitions with intellisense and autocomplete support |
| 60 | +- **🎯 Flexible Script Attributes**: Support for all standard HTML script attributes including: |
| 61 | + - `async` and `defer` execution modes |
| 62 | + - `type` specification (text/javascript, module, importmap, etc.) |
| 63 | + - `integrity` for subresource integrity verification |
| 64 | + - `nonce` for Content Security Policy compliance |
| 65 | + - `crossOrigin` and `referrerPolicy` for CORS handling |
| 66 | + - `fetchPriority` for resource loading optimization |
| 67 | + - Custom `data-*` attributes support |
| 68 | + |
| 69 | +### Technical Details |
| 70 | + |
| 71 | +- **DOM Integration**: Flexible container targeting with fallback to `document.head` |
| 72 | +- **Promise-Based API**: Async/await compatible with proper error handling |
| 73 | +- **Event Handling**: Built-in `onLoad` and `onError` callback support |
| 74 | +- **Content Injection**: Support for both `innerHTML` and `textContent` with security considerations |
| 75 | +- **Cache Management**: Automatic cache invalidation when scripts are removed from DOM |
| 76 | +- **Type Safety**: Comprehensive TypeScript definitions for all HTML script element properties |
| 77 | + |
| 78 | +### API |
48 | 79 |
|
49 |
| -- Utility function to dynamically load external scripts into the browser. |
| 80 | +- `loadScript(src, options?, container?)` - Main function returning `Promise<HTMLScriptElement>` |
| 81 | +- `LoadScriptOptions` - Comprehensive options interface with full HTML script attribute support |
| 82 | +- Built-in type definitions for `CrossOrigin`, `FetchPriority`, `ReferrerPolicy`, and `ScriptType` |
0 commit comments