How to Remove Unused CSS and JavaScripts in WordPress

JavaScripts and CSS gives a great look and functions to a website. But these type of assets takes lots of time to load. So, it is always recommend to use less scripts and styles in your site pages for better performance. On most of the pages there is no use some assets. For Example On contact us page of your site, it makes no sense if your theme load script for related posts, sharing buttons etc. So, today in this article Im going to tell you the way to detect and remove those unused CSS and JavaScripts from your WordPress sites pages and posts.

Google Pagespeed insights and other website speed testing tools also advice its users to optimize and reduce the number of JavaScripts and CSS assets. Lets discuss some benefits of using less CSS and JavaScripts files on your WordPress site.

  • Reduces page total size
  • Decrease the number of HTTP requests
  • Reduce page loading time
  • Google loves faster websites

How to Detect and Remove Unused CSS and JavaScripts from WordPress site Homepage

First we need to install a free plugin called WP Asset Clean Up. You can install it directly from your WordPress site Dashboard. This plugin helps you to detect and selectively remove unused assets from your website pages and posts. After installing this plugin a icon named WP Asset Clean Up will be automatically added to your WordPress Dashboard menu. Just click on this icon. Now you see a page like below picture. In this page you will see all CSS and JavaScripts that loads on homepage of your site.

Now you have to select those styles and scripts that you dont want to load in homepage of your site. For example i selected simple social icons, comment luv, related posts CSS and Javascripts files. Because there is no use of these assets in homepage of my site. After selecting, just click on save changes. Now this plugin will automatically stop loading the selected assets on your homepage.

How to Remove Unused CSS & JavaScripts from Your WordPress Site Blog Posts and Pages

We dont need to install any other plugin to remove unwanted assets from blog posts and pages. The same plugin that we used for homepage also helps you to remove unused styles and scripts from your blog posts and pages. Just go to Posts section in WordPress dashboard and open any post in WordPress post editor whos unused assets you want to remove. Now Scroll down, there you will see WP asset clean up section. In this section the plugin will show all styles and scripts that loads on that post.

Now you have to select CSS and Javascripts that you dont want to load on that post. After selecting just update the post. Then plugin will automatically stop loading selected assets on that post. In same way you can remove unwanted styles and scripts from your site another pages.

I hope above guide will help you to clean up unwanted styles and scripts from your WordPress site. If you have any question related to this posts then just leave your message below in comments. And dont forget to share this post with your friends if it helped you.

Leave a Reply

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