@@ -14,18 +14,19 @@ Better Privacy, Performance, and DX for Third-Party Scripts in Nuxt Apps.
14
14
15
15
All the features from Unhead [ useScript] ( https://unhead.unjs.io/usage/composables/use-script ) :
16
16
17
- - 🦥 Lazy, but fast: ` defer ` , ` fetchpriority: 'low' ` , early connections (` preconnect ` , ` dns-prefetch ` )
18
- - ☕ Loading strategies: ` idle ` , ` manual ` , ` Promise `
17
+ - ☕ Loading strategies: ` manual ` , ` Promise `
19
18
- 🪨 Single script instance for your app
20
19
- 🎃 Events for SSR scripts: ` onload ` , ` onerror ` , etc
21
20
- 🪝 Proxy API: call the script functions before it's loaded, noop for SSR, stubbable, etc
22
21
- 🇹 Fully typed APIs
23
22
24
23
Plus Nuxt goodies:
25
24
25
+ - 🦥 ` onNuxtReady ` Loading strategy
26
26
- ⏬ Serve third-party scripts from your own server
27
27
- 🕵️ Privacy Features - Trigger scripts loading on consent.
28
28
- 🪵 DevTools integration - View your script with their status and see function logs
29
+ - (TODO) Automatic Early connections (` preconnect ` , ` dns-prefetch ` )
29
30
30
31
## Background
31
32
@@ -107,9 +108,7 @@ Nuxt Scripts provides a `createScriptConsentTrigger` composable that allows you
107
108
You can either use it by providing a resolvable consent (ref, promise) option or by using ` accept() ` .
108
109
109
110
``` ts
110
- export const agreedToCookiesScriptConsent = createScriptConsentTrigger ({
111
- honourDoNotTrack: true ,
112
- })
111
+ export const agreedToCookiesScriptConsent = createScriptConsentTrigger ()
113
112
// ...
114
113
useScript (' https://www.google-analytics.com/analytics.js' , {
115
114
trigger: agreedToCookiesScriptConsent
@@ -123,7 +122,6 @@ const agreedToCookies = ref(false)
123
122
useScript (' https://www.google-analytics.com/analytics.js' , {
124
123
// will be loaded in when the ref is true
125
124
trigger: createScriptConsentTrigger ({
126
- honourDoNotTrack: true , // optional, disabled by default
127
125
consent: agreedToCookies
128
126
})
129
127
})
0 commit comments