Skip to content

Conversation

@harlan-zw
Copy link
Collaborator

πŸ”— Linked issue

#467

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Allows us to register global / registry scripts that have more granular triggers from nuxt.config.

Load GA after 1 second idle timeout

export default defineNuxtConfig({
  scripts: {
    registry: {
      googleAnalytics: [{
        id: 'GA_MEASUREMENT_ID'
      }, {
        trigger: { idleTimeout: 1000 }
      }]
    }
  }
})

Load a chat widget only on interaction

export default defineNuxtConfig({
  scripts: {
    globals: {
      chatWidget: ['https://widget.example.com/chat.js', {
        trigger: { interaction: ['scroll', 'click', 'touchstart'] }
      }]
    }
  }
})

@vercel
Copy link

vercel bot commented Sep 24, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
scripts-docs Ready Ready Preview Comment Sep 24, 2025 6:18am
scripts-playground Ready Ready Preview Comment Sep 24, 2025 6:18am

@pkg-pr-new
Copy link

pkg-pr-new bot commented Sep 24, 2025

Open in StackBlitz

npm i https://pkg.pr.new/nuxt/scripts/@nuxt/scripts@515

commit: baec1f2

@harlan-zw harlan-zw merged commit 6fbeb69 into main Sep 24, 2025
9 checks passed
@harlan-zw harlan-zw deleted the feat/new-event-triggers branch September 24, 2025 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants