NuxtN
Nuxt17mo ago
Muse

Build script and then inject into <head>

I have a
.ts
file that contains an
import
statement to use a function from a third-party package.

This script needs to be compiled and then loaded as close to the top of the <head> as possible.

Is there an existing way to do this easily in Nuxt 3? I'm also open to other alternatives that are equivalent to loading the script inside <head> without necessarily putting it there, e.g. calling the function inside that
.ts
file in a hook somewhere?

This is used for monitoring page performance so the browser agent needs to run as early as possible.
Was this page helpful?