Dev.to WebDev 🛠 Dev 👁 0 📖 1 min read

Two ES module script tags, same src, only one runs: a debugging story

I migrated a landing page to a new domain and left the old analytics beacon tag in place "temporarily," alongside the new one. Two <script type="module" src="https://static.cloudflareinsights.com/beacon.min.js"> tags, id

I migrated a landing page to a new domain and left the old analytics beacon tag in place "temporarily," alongside the new one. Two <script type="module" src="https://static.cloudflareinsights.com/beacon.min.js"> tags, identical src, different data-cf-beacon token attribute.

Traffic on the new domain's analytics property stayed at exactly zero for days. Not low — zero.

Here's the part that isn't obvious: browsers deduplicate ES module fetches by URL, per document. A type="module" script isn't like a classic <script> tag that each instance executes independently — the module graph is built once per unique specifier and cached. Two tags, same src, means one fetch and one execution, using whichever tag's attributes got resolved first.

So the second tag's token was never read. All the traffic was still being recorded — just under the OLD analytics property, silently.

// how I actually found it — not by staring at the dashboard,
// but by checking what fired
performance.getEntriesByType('resource')
  .filter(r => r.name.includes('cloudflareinsights'))
// only ONE beacon.min.js entry, despite two script tags

The fix was deleting the stale tag. The lesson was: a metric reading exactly zero for longer than plausible is a signal to check the instrumentation, not just the dashboard.

I ran into this building fundingsignals.net (a small API for SEC funding-filing data) — happy to go deeper on the module-dedup behavior if useful to anyone else debugging analytics gaps.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.