Google Tag Manager Can Slow a Next.js Site; Deferring Tags Until Interaction Fixed Blocking Time

A developer reports that Google Tag Manager, carrying GA4 and Google Ads, accounted for most of the blocking time on their Next.js homepage in a Lighthouse mobile test. Blocking time from third-party scripts fell from 4,335 ms to 0 ms after the tags were moved behind the visitor's first interaction, without removing any of them. The article explains that Tag Manager acts as a loader, so every tag added to it adds download and execution work that competes with the page's own code. It compares Next.js loading options, noting that the official third-parties package still loads tags while the page is settling, and that the worker strategy is experimental and limited to the Pages Router. The author states the homepage's mobile PageSpeed score rose from 54 to 99, though part of that gain came from other fixes.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in