Skip to content
This repository was archived by the owner on Oct 1, 2025. It is now read-only.
This repository was archived by the owner on Oct 1, 2025. It is now read-only.

Head scripts are reappended and reexecuted on navigation #381

@guanzo

Description

@guanzo

Version

2.7.1

Reproduction link

https://github.com/guanzo/codesandbox-nuxt

Steps to reproduce

$ git clone https://github.com/guanzo/codesandbox-nuxt nuxtbug
$ cd nuxtbug
$ npm i
$ npm run generate
$ npx http-server dist

Open the webpage and dev tools, go to the Elements tab, expand the <head> node

Note the position of the element

<script data-n-head="true" src="https://arc.io/widget.js?MURGrEjPmB6gVvzyvpbDut" async=""></script>

Note the element <div id="arc-widget"></div> at the bottom of <body>. This element is created when the arc.io/widget.js script is loaded.

Click the "test" link

The <head> is updated and the script has been appended to the bottom of <head>, causing it to execute again, and now there are 2 #arc-widget elements.

What is expected ?

A script is loaded once across all navigations.

What is actually happening?

A script is loaded twice across all navigations.

Additional comments?

Related to nuxt/nuxt#3396.

This only occurs when each nuxt page has its own title. When nuxt updates the page title on navigation, the script is reappended. The hid attribute on the script tag doesn't fix it.

This bug report is available on Nuxt community (#c9269)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions