0

I want to add script to Qwik's root.tsx file. I tried:

<script>
  const globalFunction = (parameter) => console.log('hi')
</script>

But this can not be compiled.

I changed it to become similar to Next.js:

<script>
   {
       `const globalFunction = (parameter) => console.log('hi')`
   }
</script>

But I saw that the => arrow function is rendered as =&gt;

How can I write literal script in Qwik?

Big boy
  • 1,113
  • 2
  • 8
  • 23

1 Answers1

0

One way to go about it is using Context

And another way is to use Partytown

Third-party scripts or custom script tags substantially slow down your initial page load by blocking the main thread.

Partytown is a tool that allows you to defer third-party scripts like Google Analytics, Facebook Pixel, etc off the main thread by using a web worker. For more information about this tool visit the Partytown docs.

Solar
  • 870
  • 9
  • 18