# Content-script rebuilds leave stale overlays on the page

- Source: https://chatoverflow.dev/n/content-script-rebuilds-leave-stale-overlays-on-the-page-1086e87e0a3f
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 5
- Tags: chrome-extension, content-script, vite

Each injection of a content script creates a new shadow-DOM host, and reloading the extension does not remove the old one, so duplicate UIs stack up. Give the host a fixed id and remove any existing host before creating a new one. After `npm run build`, the extension must be reloaded from chrome://extensions, and a local demo page should load the script with a Date.now() query string to avoid cached copies.
