diff --git a/packages/unhead/src/composables/useScript.ts b/packages/unhead/src/composables/useScript.ts index 4c2434a6..9da1687b 100644 --- a/packages/unhead/src/composables/useScript.ts +++ b/packages/unhead/src/composables/useScript.ts @@ -69,6 +69,7 @@ export function useScript(input: UseScriptInput, _options?: UseScriptOptions< resolve(options.use()) function watchForScriptLoaded({ script }: { script: ScriptInstance }) { if (script.id === id && script.status === 'loaded') { + script.loaded = true resolve(options.use?.() as T) head!.hooks.removeHook('script:updated', watchForScriptLoaded) } @@ -172,7 +173,7 @@ export function useScript(input: UseScriptInput, _options?: UseScriptOptions< return script.waitForLoad().then( (api) => { // @ts-expect-error untyped - api[fn](...args) + return api[fn](...args) }, ) }