Skip to content

v1.9.0

Compare
Choose a tag to compare
@github-actions github-actions released this 25 Mar 02:17
· 200 commits to main since this release

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

   🐞 Bug Fixes

    View changes on GitHub