How to reduce unused JavaScript

By Ricardo Cruz, 2021-09-16
Published under , , .

If you want to reduce unused JavaScript, or defer loading scripts until they are required, you will have to review a handful of different techniques that may be affecting your site.

Reducing unused JavaScript not only helps to decrease bytes consumed by network activity, it directly affects the load time of the website. Having slow landing pages is one of the reasons users abandon websites, or at least decreases their confidence on the brand.

If your website is rendered entirely with JavaScript, this might be a bigger issue. We will see in depth how to avoid this Lighthouse error in depth in another dedicated post. But if your website is mostly plain, including those websites based on CMS, you can reduce the impact of this warning by following a series of steps.

Sadly, this is not one of the low hanging fruits to improve your load times, like properly sizing your images. In this case, the more you read, the better. Here is a list of some of the best tutorials for fixing performance issues caused by an excessive use of JavaScript:

  1. Remove unused JavaScript
  2. Using Chrome’s Coverage to fix the issue
  3. How to remove unused JavaScript in WordPress

As a rule of thumb (and this applies also to plugins or social media buttons), if you don’t need it, just remove it.

1. Remove unused JavaScript –

Remove unused JavaScript

In this generic article you will find linked resources for detecting chunks of JavaScript code being sent to the browser, but not being used. You will encounter plenty of examples of using Chrome for this.

Read the article

3. Using Chrome’s Coverage to fix the issue

Learn how to use Chrome's Coverage tool to reduce unused JavaScript

Sitebulp crafted another article about on this topic, short and to the point. Use Chrome’s Coverage tool to put your website’s JavaScript under weight watch.

Read the article

2. How to remove unused JavaScript in WordPress – Online Media Masters

How to remove unused JavaScript in WordPress

If you happen to use WordPress, it is a common problem to have issues with themes, as they normally come plagued with JavaScript that you won’t ever use. There are specific techniques you can use to reduce it, Online Media Masters wrote an extensive article with everything you need to know, like minifying or disabling jQuery.

Read the article


JavaScript can be both, wonderful and problematic. Use it like salt, just as much as necessary or your website will have a slow taste for your users, inedible.

Do you have any other article link that is relevant?, I’m all eyes and ears in Twitter.

Discover how to get 100% in performance score

FREE, as in beer. You will NOT be asked to fill your email.

Keep Readinig

Using Custom Cell Renderers in Xojo


I wrote a tutorial in their blog about using custom cell renderers in your Xojo Web projects. Another one will follow, where you will learn how to go beyond and create your own cells for your WebListView controls.