@@ -14,18 +14,19 @@ Better Privacy, Performance, and DX for Third-Party Scripts in Nuxt Apps.
1414
1515All the features from Unhead [ useScript] ( https://unhead.unjs.io/usage/composables/use-script ) :
1616
17- - 🦥 Lazy, but fast: ` defer ` , ` fetchpriority: 'low' ` , early connections (` preconnect ` , ` dns-prefetch ` )
18- - ☕ Loading strategies: ` idle ` , ` manual ` , ` Promise `
17+ - ☕ Loading strategies: ` manual ` , ` Promise `
1918- 🪨 Single script instance for your app
2019- 🎃 Events for SSR scripts: ` onload ` , ` onerror ` , etc
2120- 🪝 Proxy API: call the script functions before it's loaded, noop for SSR, stubbable, etc
2221- 🇹 Fully typed APIs
2322
2423Plus Nuxt goodies:
2524
25+ - 🦥 ` onNuxtReady ` Loading strategy
2626- ⏬ Serve third-party scripts from your own server
2727- 🕵️ Privacy Features - Trigger scripts loading on consent.
2828- 🪵 DevTools integration - View your script with their status and see function logs
29+ - (TODO) Automatic Early connections (` preconnect ` , ` dns-prefetch ` )
2930
3031## Background
3132
@@ -107,9 +108,7 @@ Nuxt Scripts provides a `createScriptConsentTrigger` composable that allows you
107108You can either use it by providing a resolvable consent (ref, promise) option or by using ` accept() ` .
108109
109110``` ts
110- export const agreedToCookiesScriptConsent = createScriptConsentTrigger ({
111- honourDoNotTrack: true ,
112- })
111+ export const agreedToCookiesScriptConsent = createScriptConsentTrigger ()
113112// ...
114113useScript (' https://www.google-analytics.com/analytics.js' , {
115114 trigger: agreedToCookiesScriptConsent
@@ -123,7 +122,6 @@ const agreedToCookies = ref(false)
123122useScript (' https://www.google-analytics.com/analytics.js' , {
124123 // will be loaded in when the ref is true
125124 trigger: createScriptConsentTrigger ({
126- honourDoNotTrack: true , // optional, disabled by default
127125 consent: agreedToCookies
128126 })
129127})
0 commit comments