

If you're using Beaver Builder, this post can help you remove these unnecessary scripts.ĭo you find it helpful for you? If you have any questions, leave a comment. Besides, you should also remove unused scripts and styles in plugins.

So by these 2 methods, you have one more way to improve your website loading speed and performance. Remove bbPress scripts on non-bbPress pagesĪdd_filter( 'bbp_default_scripts', function ( $scripts )Īdd_action( 'wp_enqueue_scripts', function ()įinally, save the remove-resources.php file and activate the created plugin to make it work.

Also, you can use the wp_dequeue_script function to remove scripts.įor example, I’m removing styles and scripts of Jetpacks and BBPress by adding the below code into the remove-resources.php file: // Remove styles of pluginĪdd_filter( 'jetpack_implode_frontend_css', '_return_false' ) Īdd_filter( 'bbp_default_styles', '_return_empty_array' ) To remove the unused CSS / JS files, we use the _return_false() or _return_empty_array() function. * Description: remove unused CSS JS files php file named remove-resources.php with the following content: Go to the wp-content > plugins, create a new folder named remove-resources that includes a. Now, let’s create a plugin to remove the unused CSS / JS files! It will help you proactively control how to load the CSS / JS files. Read more here.īesides, you may need the conditional tags of WordPress to remove the unused CSS / JS files on a certain page or post.

Method 1: Use Plugin to Remove the Unused CSS / JS Files They are using a plugin and manual-removing. In this article, I suggest 2 methods to remove CSS or JS files in WordPress. The unused code is marked with a red color. You can click an URL to find out exactly what code isn’t used. Next, click settings icon > More tools > Coverage.Īfter that, click the Reload button (the circle arrow icon).Ĭhrome will check your website and export a report as follows: Chrome will analyze your website to find unused CSS / Javascript filesįocus on the Usage Visualization section and the correlation rate between used and unused code: red color means the number of unused bytes and blue color means the number of used bytes. To open Chrome DevTools, press Ctrl + Shift + I or click the right mouse button and choose Inspect. The most convenient and easy way to do it is using Coverage Tab in Chrome DevTools. Method 2: Manually Remove the CSS / JS Files by Creating a New PluginĪnalyze and Find the Unused CSS / JavaScript Filesīefore removing CSS / JavaScript files in WordPress, we should check and briefly analyze them. Analyze and Find the Unused CSS / JavaScript Files
