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, 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.
The Root Cause
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'))
Result: only ONE beacon.min.js entry, despite two script tags.
The Fix
The fix was deleting the stale tag.
The Lesson
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.
Comments
No comments yet. Start the discussion.