Skip to content

Add web worker support (Partytown) #182

Description

@harlan-zw

🆒 Your use case

Out-of-the-box Nuxt Scripts won't provide any significant performance gains for most people, the only performance improvement is loading third-party scripts as Nuxt app hydrates, instead of beforehand, which may help with reducing blocking time.

We provide some options that can solve these performance issues for third-party scripts through delaying scripts until they're needed or Facade components.

However, some users will need to load these scripts as quickly as possible without slowing down the Nuxt app hydration. This is the ideal use case for web workers (Partytown).

Related #56

🆕 The solution you'd like

We should be able to provide a simple flag to the useScript composable that will offload it to the webworker, no other functionality should change.

Under the hood, this will use Partytown. We will either integrate directly with https://github.com/nuxt-modules/partytown or write bespoke code.

useScript('/script.js',{webworker: true,})

All other functionality should work the same.

🔍 Alternatives you've considered

No response

ℹ️ Additional info

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions