1 Audit your site before you touch anything
The first mistake is ripping out jQuery before you know what depends on it. One free tool will show you exactly what your site loads, how heavy it is, and whether jQuery is even the problem. I ran a 5-year-old WordPress site through this and found three plugins calling jQuery twice. That was the whole issue.
2 Replace jQuery with a $0 vanilla JS snippet library
If you only use jQuery for a few things — show/hide a menu, a smooth scroll, a basic click event — a 3kb vanilla JavaScript file replaces all of it. The library is called Cash.js and it uses the exact same dollar-sign syntax jQuery made famous. I swapped it into a small business site in about 20 minutes and shaved 80kb off the page.
3 Defer or async-load jQuery if you are keeping it
Sometimes you cannot remove jQuery — an old plugin, a paid theme, a form you do not have time to rebuild. Fine. You can at least stop it from blocking your page while it loads. A single line added to your WordPress functions.php file tells the browser to load jQuery after the visible page is already painted. Most visitors will never notice jQuery is even there.
4 Bundle and minify whatever JavaScript you keep
Every separate JavaScript file is a separate trip to the server. Three files that could be one means three times the waiting. A bundler smashes them together and strips out spaces and comments so the file is as small as possible. For someone running a WordPress or static site in North Port advertising lawn care or home services, this is the difference between a 2-second load and a 6-second load on a mobile phone in the afternoon heat when LTE is congested.
5 Move to a modern framework if you are building something new
If you are starting a new project — not patching an old one — there is no reason to start with jQuery in the first place. Alpine.js handles 90 percent of what people used jQuery for with a file that is 15kb. It is what I would tell my neighbor to use if they asked me in the driveway. The learning curve is about one weekend.
6 Learn the single most useful jQuery replacement pattern
If you want to understand what you are doing rather than just copying someone else's fix, one short book covers modern DOM manipulation without any library. Knowing this protects you from the next time a developer hands you a site built on a framework nobody uses anymore. A retired engineer in Port Charlotte told me this book was the first technical thing that made sense since his COBOL days, which I thought was a good sign.
jQuery is not the problem — leaving it untouched for another five years while your page loads like it's 2009 is.
isnotbadforyou.com/jquery · A North Port neighbor's honest take
This page may contain affiliate links. If you buy something through them, we earn a small commission at no extra cost to you. We only recommend things we'd use ourselves.