Removing Unneeded Jetpack Code Slowing Down WordPress Sites

Categorized as Speed
Jetpack Featured Image

Time

>20 minutes

Difficulty

3/10

Impact

2/10

Speed Up Jetpack

Jetpack is a default of many WordPress websites that was built by the company responsible for developing WordPress itself. Unfortunately, the plugin has a lot of features and most sites don’t use or need them all, causing sites to load slower when all these features are loaded on each page.

This can be fixed for most sites by removing these scripts from pages that are associated with the unneeded features. Since this is different for every site, it’s impossible to provide a blanket recommendation outside of a few basic changes below.


Stripping out the slow, unneeded Jetpack code

Most sites don’t need Jetpack loaded on every single page. While some sites may use few Jetpack features, others may use it for a lot of things. The safest way to remove unneeded code without compromising functionality is by creating a child theme that removes some of the more broad, largely unused code that most sites do not need on their WordPress websites.

Step 1: Create a child theme or your existing theme if you haven’t already

Step 2: Add the code below to your functions.php file

This can be done by going to Appearance > Theme Editor > [select the child theme] > functions.php — then add the code to that file by copy-pasting below

/**
 * Manage Jetpack CSS largely unused.
 */
add_filter( 'jetpack_implode_frontend_css', '__return_false', 99 );
add_filter( 'jetpack_sharing_counts', '__return_false', 99 );

If you’re using Ezoic Leap, after implementing this change make sure to clear the cache inside the caching app and clear the cache in the Leap Optimization Settings tab as well (two caches to clear).