diff --git a/docs/content/docs/1.guides/1.registry-scripts.md b/docs/content/docs/1.guides/1.registry-scripts.md index ade24a9fe..ebc9d5b60 100644 --- a/docs/content/docs/1.guides/1.registry-scripts.md +++ b/docs/content/docs/1.guides/1.registry-scripts.md @@ -68,8 +68,7 @@ NUXT_PUBLIC_SCRIPTS_CLOUDFLARE_WEB_ANALYTICS_TOKEN=YOUR_TOKEN export default defineNuxtConfig({ scripts: { registry: { - // loads the script - cloudflareWebAnalytics: true, + cloudflareWebAnalytics: { trigger: 'onNuxtReady' }, }, }, runtimeConfig: { @@ -100,7 +99,7 @@ You can do this by providing a `mock` value to the registry script. export default defineNuxtConfig({ scripts: { registry: { - googleTagManager: true, + googleTagManager: { trigger: 'onNuxtReady' }, }, }, $development: { diff --git a/docs/content/docs/4.migration-guide/1.v0-to-v1.md b/docs/content/docs/4.migration-guide/1.v0-to-v1.md index 9fcbda7f0..69f7c8e6a 100644 --- a/docs/content/docs/4.migration-guide/1.v0-to-v1.md +++ b/docs/content/docs/4.migration-guide/1.v0-to-v1.md @@ -63,9 +63,9 @@ Enable the embeds you need in your `nuxt.config`: export default defineNuxtConfig({ scripts: { registry: { - xEmbed: true, - instagramEmbed: true, - blueskyEmbed: true, + xEmbed: { trigger: 'onNuxtReady' }, + instagramEmbed: { trigger: 'onNuxtReady' }, + blueskyEmbed: { trigger: 'onNuxtReady' }, }, }, }) @@ -192,14 +192,56 @@ Server-side geocoding proxy to reduce billing costs and hide API keys. Automatic v1 redesigns how registry entries work. The key change: **presence enables infrastructure, `trigger` enables auto-loading**. +### Scripts No Longer Auto-Load Without a Trigger + +In v0, any configured script auto-loaded globally. In v1, scripts require an explicit `trigger` to auto-load. Without one, the script registers infrastructure (proxy routes, types, bundling) but does **not** load on the page. + +If you had a config like this in v0: + +```ts [v0 nuxt.config.ts] +export default defineNuxtConfig({ + scripts: { + registry: { + googleAnalytics: { id: 'G-XXXXXX' }, + } + } +}) +``` + +You need to add a trigger in v1: + +```ts [v1 nuxt.config.ts] +export default defineNuxtConfig({ + scripts: { + registry: { + googleAnalytics: { id: 'G-XXXXXX', trigger: 'onNuxtReady' }, + } + } +}) +``` + +If you only need infrastructure without loading the script on the page, set `trigger: false` explicitly. This registers proxy routes, TypeScript types, and bundling config, but no `