Packages

@unhead/addons

3.4.3 · 13 Oct 2026MIT68.7k / weekRepositoryHomepagenpmAtom feed

Your version

1.9.0

25 Mar 2024Where it was published

1.11.21 is the newest release of 1.x.

In short

5 breaking1 fixed

  • Breaking

    script: Remove script:transform hook

  • Breaking

    script: $script promisable, remove waitForLoad

  • Breaking

    script: Remove $script.loaded

  • Breaking

    script: EventContext option, skip onabort, onprogress events

  • Breaking

    script: Remove early connections

Release note

Release 1.9.0 - useScript Stable

useScript is built to provide better performance and DX when working with Third-Party Scripts. In this release we reduce the composable size has been reduced by 30% with some notable breaking changes:

Removed trigger idle

While this was handy in user-land, providing support for it meant providing a polyfill for window.requestIdleCallback due to limited browser support. Most integrations will already ship a polyfill for this so it added extra unnecessary weight.

If you'd like to re-implement this behaviour there's a recipe on the docs and you should provide your own polyfill (if needed).

Early connections removed

When using the composable it would try and guess how the script is being used and append a dns-prefetch or a preconnect <link> depending on usage. To reduce the composable weight, this should now be implemented in user or integration land.

<link rel="dns-prefetch" href="<script-domain>" />

Awaiting Script Changes

When you wanted to avoid using the Proxy API and use the script instance directly, you could use the $script.waitForLoad() function. To reduce the weight, the $script object itself is now a promise:

const { $script } = useScript('<src>', { use: () => window.myScript })

$script
	.then(instance => {
		// script is loaded, instance is the same as window.myScript 
	})
    .catch(() => {
       // script failed to load
    })

Changelog

Breaking Changes

  • Breaking

    script: Remove script:transform hook

  • Breaking

    script: $script promisable, remove waitForLoad

  • Breaking

    script: Remove $script.loaded

  • Breaking

    script: EventContext option, skip onabort, onprogress events

  • Breaking

    script: Remove early connections

Bug Fixes

  • script: Typed data-* keys

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.