vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
13.25k stars 2.14k forks source link

`async` attribute not added in dev server #4272

Closed thdoan closed 1 month ago

thdoan commented 1 month ago

Describe the bug

I followed this example to add a GA tag, but on the dev server I do not see the async attribute:

image

I'm only developing, so don't know if this is a bug or the expected behavior only on the dev server.

Reproduction

  1. Add GA tag as shown in this example
  2. Run npm run dev to start the dev server
  3. Load your site

Expected behavior

<script async src="https://www.googletagmanager.com/gtag/js?id=TAG_ID"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'TAG_ID');
</script>

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Memory: 13.10 GB / 31.95 GB
  Binaries:
    Node: 18.20.4 - C:\Program Files\nodejs\node.EXE
    npm: 10.7.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (127.0.2651.74)
    Internet Explorer: 11.0.19041.4355
  npmPackages:
    vitepress: latest => 1.3.4

Additional context

No response

Validations

thdoan commented 1 month ago

UPDATE: I just published and noticed the async attribute is on the production site, so it's only missing on the dev server. Not sure if this is the intended behavior. If it is, you can close this ticket.

brc-dd commented 1 month ago

fixed in 461a5b001d29f95169f60fe28bc610e3f6e8fd66