Skip to content
Advertisement

Force Nuxt to run script tag

I have a script on a page:

JavaScript

If I go to the page via a NuxtLink in the navigation the script runs, however if I type the URL to the browser address bar it doesn’t.

Is there a way to force the NuxtLink result when the page is accessed directly?

The script tag is coming from a CMS so there isn’t a way to hardcode it somewhere nice.

Advertisement

Answer

There is a head method (Docs) which will let you to load external scripts but I can’t find the documentation for the script property.

I would dynamically load the script only on the client side like this:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement