The Lean Cheat Sheet for When You Can’t Avoid Plugins

Download the FREE Plugin Cheat Sheet: Proven lightweight picks to reduce page weight, boost speed, and streamline your WordPress stack.

Lean Plugin Cheat Sheet Preview

How to Remove jQuery from WordPress

jQuery once helped sites run everywhere, but today it’s often just extra weight. This quick guide shows you how to remove it safely, speed up WordPress, and shrink your site’s carbon footprint, all in a few straightforward steps.

Why consider removing jQuery?

Removing jQuery frees your pages from a legacy dependency that blocks rendering, slows time to interact, and adds carbon overhead. Modern browsers replicate almost every jQuery helper natively, so dropping it can cut 30–100 kB, improve Core Web Vitals, and even lower hosting energy costs. Faster sites convert better and rank higher, win‑win.

Ecological tipHEADS-UP: Taking jQuery out can break interactive features if they still rely on it. Always clone your site or use a staging environment before making changes, and click through every key page to be sure nothing snaps.

Spot the jQuery culprit in your site

1. Run a quick Coverage audit in DevTools

Open Chrome DevTools → Coverage. Reload the page and look for jquery.js. The Unused bytes column shows how much script ships but never runs.

2. Check the payload in the Network waterfall

Still in DevTools, filter “jquery”. You’ll often see 30–100 kB for jQuery and another hit for jQuery Migrate.

3. Note your baseline metrics

Grab your Largest Contentful Paint (LCP) and First Input Delay (FID) from the PageSpeed Insights API. Record an estimated CO₂ per view with Website Carbon.

Green hosting server icon

Ready for Faster, Greener Hosting?

We recommend Krystal - fast, reliable, powered by 100% renewable energy. It's a host we trust and a smart move for a cleaner web.

Audit theme & plugin dependencies on jQuery

1. Is jQuery Migrate still loading?

Its presence often means legacy code. Removing it alone can shave ~30 kB.

2. Hunt for $('…') calls

Search your theme and active plugins for $(' or jQuery(. Page-builder favourites (Divi, Elementor) pop up here.

3. Flag security risks of legacy jQuery 1.x

Versions pre-3.6.0 carry known CVEs. Update, replace, or proceed with caution.

Choose your removal strategy

Where do I paste these snippets?
Add any PHP examples below to your child theme’s functions.php file or, if you prefer to avoid editing theme files, use the free Code Snippets plugin. Both methods load the code site‑wide without touching core files.

1. Disable jQuery Migrate (quick win)

add_action( 'wp_default_scripts', function( $scripts ){
  if ( ! is_admin() && isset( $scripts->registered['jquery'] ) ) {
    $scripts->remove( 'jquery-migrate' );
  }
} );

2. Dequeue jQuery site-wide

function lw_remove_jquery() {
  if ( ! is_admin() ) {
    wp_deregister_script( 'jquery' );
    wp_dequeue_script( 'jquery' );
  }
}
add_action( 'wp_enqueue_scripts', 'lw_remove_jquery', 20 );

3. Lazy-load jQuery only where essential

Register jQuery normally, then enqueue it conditionally (e.g., only on contact-form pages).

4. Swap to native APIs (biggest win)

Replace jQuery helpers with Vanilla JavaScript:

// jQuery
$('.btn').addClass('active');

// Vanilla JS
document.querySelectorAll('.btn')
        .forEach(el => el.classList.add('active'));

Scroll events? Use the Intersection Observer API.

Test changes in a safe sandbox

1. Spin up staging

Most hosts offer one-click staging; Local WP works offline too.

2. Check block-theme vs classic-theme compatibility

Block themes rarely miss jQuery. Classic themes may.

3. Watch live Real-User Monitoring (RUM)

Cloudflare Browser Insights or Splitbee can surface LCP/FID in real time.

4. Roll back fast

Keep an unedited backup handy until you’ve clicked every primary journey.

Deploy and track results

1. Re-run PageSpeed Insights

Confirm smaller transfer size and no blocking script warnings.

2. Monitor Core Web Vitals

Aim for LCP < 2.5 s and FID < 100 ms.

3. Measure carbon savings

Every 100 kB trimmed prevents ~7 kg CO₂ per 10 k page views annually.

4. Celebrate the ROI

Deloitte’s 2023 report links 0.1 s speed improvements to a 3–7 % conversion uplift. Show that to your marketer.

Green service optimisation icon

The Quick Fix for a Slow, Heavy Site

We optimise your site for speed, efficiency and sustainability. No rebuild. No delays. Just better performance and a lighter footprint.


Wrap Up

Removing jQuery is one of the fastest paths to a leaner, greener WordPress. Pick a step, try it on staging, and watch your site, and carbon ledger, lighten within the hour.

Profile photo of Neil Beckett

Neil Beckett

Neil is the founder of LeanWebs, with over ten years of experience in WordPress development. What started as a love for site speed turned into a mission to build faster, lighter, more sustainable websites.