Script
External script loader component that dynamically loads JavaScript files and manages script lifecycle with automatic cleanup.
Source
Type Definition
function Script({
src,
ref,
...props
}: {
src: string
ref?: React.Ref<HTMLScriptElement>
} & React.ScriptHTMLAttributes<HTMLScriptElement>): JSX.Element
Parameters
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
src | string | ✅ | - | URL of the JavaScript file to load |
ref | React.Ref<HTMLScriptElement> | ❌ | - | Reference to the script element |
...props | React.ScriptHTMLAttributes<HTMLScriptElement> | ❌ | - | Additional HTML script element attributes (async, defer, etc.) |
Last modified: 2025-06-10