WP Manifestindependent plugin directory
manifest / performance / google-site-kit-gtag-script-deprioritization

Site Kit GTag Script Deprioritization

Moves the GTag script to the footer, adds fetchpriority=low, and eliminates the dns-prefetch resource hint to deprioritize to prevent it from impacting the critical rendering path.

by Weston Ruter · github.com/westonruter/google-site-kit-gtag-script-deprioritization · website

1stars
0forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/westonruter/google-site-kit-gtag-script-deprioritization/archive/refs/heads/main.zip

Declares an update source (https://github.com/westonruter/google-site-kit-gtag-script-deprioritization), so updates arrive through the plugin's own updater.

From the readme

Site Kit GTag Script Deprioritization # Description ## This plugin deprioritizes the loading of the GTag script in the Site Kit by Google plugin to attempt to reduce network contention with loading resources in the critical rendering path (e.g. the LCP element image). It deprioritizes the GTag script by: 1. Adding fetchpriority="low" to the script tag. 2. Moving the script tag from the head to the footer (but keeping the dataLayer and gtag() inline script in the head). 3. Removing the dns-prefetch for www.googletagmanager.com. This does not primarily benefit Chrome since that browser already gives async scripts a priority of low. It does benefit Safari and Firefox, however, since they have a default medium/normal priority. Here is the performance impact in Firefox using a patched version of benchmark-web-vitals with Firefox support: | URL | Before | After | Diff (ms) | Diff (%) | |:------------------|-------:|------:|----------:|---------:| | FCP (median) | 75 | 74 | -1.00 | -1.3% | | LCP (median) | 76 | 75 | -1.00 | -1.3% | | TTFB (median) | 38 | 38 | 0.00 | 0.0% | | LCP-TTFB (median) | 41 | 40 |

Read the full README on GitHub →