Chrome Prerendering Runs Your JavaScript Before You Even Press Enter: What It Means for Analytics and APIsBrief · digest for November 25
Brief≈ 1 min

Chrome Prerendering Runs Your JavaScript Before You Even Press Enter: What It Means for Analytics and APIs

Start typing a site address in Chrome, and the browser may already load a history suggestion in the background. When the address bar is confident you're going there (you can see its scores at chrome://predictors), Chrome renders the full page in a hidden tab and executes its JavaScript before you ever press Enter.

At Synthesia, engineer Tom Bennet chased an onboarding bug caused by this for months. The app saved landing-page parameters once into localStorage. Coworkers would open Incognito and start typing the URL. It turned out Incognito pulls suggestions from regular history, prerenders the site in the background, and shares a single localStorage between visible and hidden tabs. The hidden tab wrote an empty snapshot, so the real navigation never overwrote it.

Debugging this is brutal. Since 2019, Chrome disables address-bar prerendering whenever DevTools is open: open the inspector, and the bug disappears. It also stays quiet in a clean profile without history or when you paste a full URL.

This affects page counters, analytics, single-use tokens, and automatic API calls on load. Before writing to storage or firing events, check document.prerendering: if it's true, defer your code until the prerenderingchange event fires on actual activation.

Want a deep diveVotes help us choose what to break down in detail. This material has 0 votes.
Sources · 2