---
title: "script:updated Hook · Unhead"
canonical_url: "https://unhead.unjs.io/docs/solid-js/head/api/hooks/script-updated"
last_updated: "2026-08-08T01:29:48.619Z"
meta:
  description: "Internal hook emitted when a managed script starts loading, loads, fails, or is removed."
  "og:description": "Internal hook emitted when a managed script starts loading, loads, fails, or is removed."
  "og:title": "script:updated Hook · Unhead"
---

Home

`
Unhead on GitHub

Switch to Solid.jsSwitch to TypeScriptSwitch to VueSwitch to ReactSwitch to SvelteSwitch to AngularSwitch to Nuxt

**Hooks**

# **script:updated Hook**

[Copy for LLMs](https://raw.githubusercontent.com/unjs/unhead/refs/heads/main/docs/head/7.api/hooks/15.script-updated.md)

The `**script:updated**` hook is emitted when a `**useScript()**` instance changes to `**loading**`, `**loaded**`, `**error**`, or `**removed**`. A new script starts in `**awaitingLoad**`, but creating it does not emit this hook until its status changes.

This hook also drives `**useScript()**`'s internal load promise and callbacks. Application code should normally use `**onLoaded()**`, `**onError()**`, `**load()**`, and `**remove()**` on the returned script instance instead.

## Hook Signature

```
export interface Hook {
  'script:updated': (ctx: {
    script: ScriptInstance<any>
  }) => void | Promise<void>
}
```

### Script Status

```
type UseScriptStatus =
  | 'awaitingLoad'
  | 'loading'
  | 'loaded'
  | 'error'
  | 'removed'
```

`**ScriptInstance**` exposes `**id**`, `**status**`, `**instance**`, `**proxy**`, `**signal**`, `**entry**`, `**load()**`, `**warmup()**`, `**remove()**`, `**setupTriggerHandler()**`, `**onLoaded()**`, and `**onError()**`. The status is read-only in the public type. Retry counters, fallback sources, loading timestamps, and an `**error**` property are not part of this API.

## Usage Example

```
import { defineHeadPlugin } from '@unhead/solid-js/plugins'

export const scriptStatusPlugin = defineHeadPlugin({
  key: 'script-status',
  hooks: {
    'script:updated': ({ script }) => {
      console.log(\`Script ${script.id}: ${script.status}\`)
    }
  }
})
```

Hook promises are not used to delay script loading or status transitions.

[~~Edit this page~~](https://github.com/unjs/unhead/edit/main/docs/head/7.api/hooks/15.script-updated.md)

[~~Markdown For LLMs~~](https://raw.githubusercontent.com/unjs/unhead/refs/heads/main/docs/head/7.api/hooks/15.script-updated.md)

**Did this page help you? **

[**ssr:rendered** Hook for inspecting or synchronously changing the serialized SSR head payload.](https://unhead.unjs.io/docs/head/api/hooks/ssr-rendered) [**Plugins** Create custom plugins with defineHeadPlugin to hook into Unhead's tag resolution, DOM rendering, and SSR lifecycle.](https://unhead.unjs.io/docs/head/api/plugins)

**On this page **

- [Hook Signature](#hook-signature)
- [Usage Example](#usage-example)