diff --git a/packages/schema/src/script.ts b/packages/schema/src/script.ts index 7201f427..2fe4cbae 100644 --- a/packages/schema/src/script.ts +++ b/packages/schema/src/script.ts @@ -18,13 +18,7 @@ export type ScriptInstance = { remove: () => boolean } & Promise -export interface UseScriptOptions extends Omit { - /** - * Should the `dns-prefetch` tag be skipped. - * - * Useful if loading the script through a local proxy. - */ - skipEarlyConnections?: boolean +export interface UseScriptOptions extends HeadEntryOptions { /** * Resolve the script instance from the window. */ @@ -35,10 +29,9 @@ export interface UseScriptOptions extends Omit stub?: ((ctx: { script: ScriptInstance, fn: string | symbol }) => any) /** * The trigger to load the script: - * - `manual` - Load the script manually by calling `$script.load()` or `$script.waitForLoad()`. + * - `manual` - Load the script manually by calling `$script.load()`. * - `Promise` - Load the script when the promise resolves. */ - trigger?: 'idle' | 'manual' | Promise trigger?: 'manual' | Promise /** * Context to run events with. This is useful in Vue to attach the current instance context before diff --git a/packages/unhead/src/composables/useScript.ts b/packages/unhead/src/composables/useScript.ts index e9ed096b..144f2478 100644 --- a/packages/unhead/src/composables/useScript.ts +++ b/packages/unhead/src/composables/useScript.ts @@ -96,14 +96,8 @@ export function useScript(_input: UseScriptInput, _options?: UseScriptOptions const trigger = options.trigger if (options.trigger) trigger instanceof Promise && trigger.then(script.load) - // if we're lazy it's likely it will load within the first 10 seconds, otherwise we just prefetch the DNS for a quicker load - maybeHintEarlyConnection(isIdle ? 'preconnect' : 'dns-prefetch') - } - else { + else script.load() - // safe to preconnect as we'll load this script quite early - maybeHintEarlyConnection('preconnect') - } function resolveInnerHtmlLoad(ctx: DomRenderTagContext) { // we don't know up front if they'll be innerHTML or src due to the transform step diff --git a/test/unhead/ssr/useScript.test.ts b/test/unhead/ssr/useScript.test.ts index 0e7521ff..8dfc366b 100644 --- a/test/unhead/ssr/useScript.test.ts +++ b/test/unhead/ssr/useScript.test.ts @@ -16,8 +16,7 @@ describe('dom useScript', () => { "bodyAttrs": "", "bodyTags": "", "bodyTagsOpen": "", - "headTags": " - ", + "headTags": "", "htmlAttrs": "", } `)