New Theme: Magma makes your WordPress site faster, smoother, and easier to manage.

Improve PageSpeed Performance Score in WordPress by Delaying JavaScript – Flying Scripts

How many times have you built a fast WordPress site with great PageSpeed scores—only to see them drop after adding Google Analytics, tracking pixels, cookie banners, or AdSense?

The score drops, the client complains, and you’re stuck explaining why their “optimized” site looks bad in PageSpeed. And let’s be honest, no one enjoys that conversation.

But I have good news: there’s something you can do about it.

Flying Scripts is a free plugin that delays JavaScript files until the user interacts with the page. That means those scripts aren’t even loaded or run until someone moves their mouse, touches the screen, or scrolls. That means a faster initial load and better performance scores.

Reduce unused JavaScript

If you’ve ever struggled with the “Reduce unused JavaScript” warning in PageSpeed Insights, this plugin can help. Run a test, open that section, and check the list of scripts.

Reduce Unused JavaScript

To delay them, copy part of the script name and paste it into the Flying Scripts settings.

For example, to delay Google Tag Manager and Google Analytics, you might enter gtag and gtm. For Facebook Pixel, use fbevents.js. For Google Adsense use adsbygoogle.js.

These keywords should match something unique in the script URL or inline code.

Flying Scripts Settings Page

Then set the timeout to 10 seconds. This timeout setting also ensures that scripts will load even if there’s no interaction at all, just with a short delay. Shorter timeouts can backfire. I’ve seen the Google bot trigger the timeout, wait for scripts to load, and end up with an even worse score. Ten seconds has worked best for me.

And no, this doesn’t mess with your users, at least not directly. They won’t notice anything. The delay mostly affects bots, and those scripts don’t help bots anyway.

You’re not breaking any rules either. Google is fine with delaying non-critical scripts that aren’t needed right away.

Exclude Pages in Disable on Pages

That said, here’s one thing to keep in mind: some scripts might be important on specific pages—like checkout or donation pages. Flying Scripts has a “Disable on Pages” feature, and I strongly recommend using it.

On one site, I forgot to exclude the checkout page, and the payment form stopped working. Luckily, I caught it early, but that kind of mistake could easily hurt conversions or lead to lost sales. So if you’re running an eCommerce site, be careful and exclude those critical pages from the delay.

Example of a Real Website with Google AdSense

On one of my own sites, the page without Google Tag Manager and AdSense had a performance score of 94.

PageSpeed Insights Performance - Without Scripts

After adding those scripts, it dropped to 60.

PageSpeed Insights Performance - With Scripts

Then I enabled Flying Scripts, and surprisingly, the score jumped to 100.

PageSpeed Insights Performance - With Scripts and Lazy-Loading

That might’ve been a lucky server load—or maybe the earlier test was just an unlucky one—but either way, the improvement was clear.

Deferring Scripts vs Lazy-Loading

You might ask how this is different from deferring scripts? With defer, scripts are downloaded immediately, but they wait to run. With Flying Scripts, they’re not even downloaded until someone interacts—or until the timeout runs out. That can really help reduce the number of requests during the initial load, especially on mobile.

Flying Scripts gives you a clean, simple way to speed up your site by delaying what doesn’t need to run right away.

Give it a try and test before and after in PageSpeed Insights. The results might surprise you.

Leave a Reply

Your email address will not be published. Required fields are marked *