Skip to content

Adds `fetchpriority=low` to the Jetpack Stats script to reduce network contention with the loading of resources in the critical rendering path. Also removes the `dns-prefetch`.

Notifications You must be signed in to change notification settings

westonruter/jetpack-stats-script-deprioritization

Repository files navigation

Jetpack Stats Script Deprioritization

Contributors: westonruter
Tested up to: 6.8
Stable tag: 0.1.0
License: GPLv2 or later
Tags: performance

Description

This plugin deprioritizes the loading of the Stats script in the Jetpack plugin to attempt to reduce network contention with loading resources in the critical rendering path (e.g. the LCP element image). It deprioritizes the script by:

  1. Adding fetchpriority="low" to the script tag.
  2. Removing the dns-prefetch for stats.wp.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.

For an example of the performance impact for this change, see the Site Kit GTag Script Deprioritization plugin.

I've proposed these changes for inclusion in Jetpack.

Installation

  1. Download the plugin ZIP from GitHub or if you have a local clone of the repo run npm run plugin-zip.
  2. Visit Plugins > Add New Plugin in the WordPress Admin.
  3. Click Upload Plugin.
  4. Select the jetpack-stats-script-deprioritization.zip file on your system from step 1 and click Install Now.
  5. Click the Activate Plugin button.

You may also install and update via Git Updater.

Changelog

0.1.0

  • Initial release.

About

Adds `fetchpriority=low` to the Jetpack Stats script to reduce network contention with the loading of resources in the critical rendering path. Also removes the `dns-prefetch`.

Topics

Resources

Stars

Watchers

Forks