Home > Back-end >  How to exclude script on certain routes in Nuxt?
How to exclude script on certain routes in Nuxt?

Time:05-07

I have a nuxt2-webapp with a lot of routes and for all routes except 2, I need a script to be injected. Is there a way to disable the injecting?

Nuxt config:

meta: [
  script: [
    {
      id: 'Cookiebot',
      src: 'https://consent.cookiebot.com/uc.js',
      'data-cbid': 'xxxxx',
      type: 'text/javascript',
      async: true,
    },
  ],
]

CodePudding user response:

No, there is no way to do so.
If you inject a script, it will be on the window object. Hence available everywhere in your DOM.

What's the issue with that? You could hide your thing with some CSS if it's annoying visually.

  • Related