🔥 🥳 Get your Wordpress Pagespeed optimized today for $99 🔥 🥳 Conditions apply.

Best ways to reduce javascript execution time in WordPress

Last updated on October 18, 2021 | By

Learn how to reduce your javascript execution time and improve Pagespeed.

How to identify large Javascript execution time in WordPress

Do a test using Pagespeed, and identify the files containing the errors.

image 2

Using Webpagetest

Do a Core Web Vitals test using Webpagetest.org, click “Total Blocking Time” and identify the javascript files with large execution time.

image 3

How to decrease javascript execution time

After identifying the errors, apply the following steps to improve the javascript execution time Pagespeed item or simply js exec. time.

Delay the plugin’s javascript 

Flying Scripts is a free, tested, and up-to-date plugin that lets you load javascript after user interaction. Install it on WordPress and place the keyword you’d want to delay the javascript plugin.

Hot to remove unused javascript using a free plugin

To find the keyword you can either use the asset name or use Chrome Dev Tools; click F12 on Chrome, click the “Network” tab, and hover over “Initiator” to see which file triggered the asset loading:

How to find unused javascript using a Chrome Dev Tools
Analytics.js was initiated by www.googletagmanager.com/gtag, we can use gtag keyword to delay analytics.js

Place the domain keyword on Flying Scripts.

Consider hosting the 3rd party heavy javascript locally on your website, and then delay it if delaying inst supported.

Switch to better plugins

Switch to plugins with the same functionality but with smaller sizes, and smaller javascript payloads.

  • Consider Novashare instead of Social Warfare.
  • Consider Crisp instead of heavy javascript chat plugins. Check this article on comparing chat plugins speed.

Apply code-splitting

If you have a WordPress website app and uses Javascript on your stack, apply code-splitting, dividing JavaScript into smaller chunks, which allows for smarter loading of the different components.

Read here how Instagram improved their infinite scrolling feed performance with 25% reduction in time taken to load photos using task priorization and other techniques.

Remove Recaptcha and use bot fighting, or delay Recaptcha Javascript

Consider using a smaller captcha such as math challenges, instead of Recaptcha. Setup Cloudflare and enable bot/email protection if it suits your spam/bot fighting.

You also can delay ReCaptcha until user-interaction to reduce js exec time, but it needs testing, as smart bots may trespass this option.

Ask the developer to improve the plugin

If you need a plugin but are having javascript issues, ask the developer to enable deactivating unused functions on the frontend.

Read here how Mercado Libre reduced their FID by 60% using code-splitting and other techniques.

Get a Core Web Vitals Boost

Send us your request!

Leave a Comment