de-queue elements<\/strong> from your functions.php file. Paste the below code on your website’s functions.php to disable unused JavaScript.<\/p>\n*\/\r\nfunction wp_remove_scripts() {\r\n\/\/ check if user is admin, therefore only logged-out users won't load the script\r\nif (current_user_can( 'update_core' )) {\r\nreturn;\r\n} \r\nelse {\r\n\/\/ Check for the page you want to target\r\nif ( is_page( 'homepage' ) ) {\r\n\/\/ Remove Scripts\r\nwp_dequeue_script( 'jquery-ui-core' );\r\nwp_deregister_script( 'jquery-ui-core' );\r\n}\r\n}\r\n}\r\nadd_action( 'wp_enqueue_scripts', 'wp_remove_scripts', 99 );<\/pre>\nThe results appear on your website when you update and save the changes. This code might not work<\/strong> properly on all the WordPress themes. Please put the code very carefully on the theme; otherwise, it could jumble up your site.<\/p>\nHowever, I recommend using Asset Cleanup<\/strong> or WP Rocket plugin if you don’t have coding knowledge. Plugins are safe and easy-to-use tools.<\/p>\n<\/span>Final Thoughts<\/strong><\/span><\/h2>\nI hope you love this article on how to remove unused JavaScript in WordPress websites<\/strong>. In this tutorial, we have learned both plugins as well as a manual method to disable unused JavaScript in WordPress.<\/p>\nThe page speed is a crucial aspect<\/strong> of the growth of a website, and unused JavaScript files severely hit it. So, it is a must to remove them. You can find various methods to remove unused JavaScript from a website but using the Asset plugin is the simplest way to do so.<\/p>\n","protected":false},"excerpt":{"rendered":"Are you looking for how to remove unused JavaScript in WordPress? Then stay connected with this post. When you test your website on Google PageSpeed Insights, unused JavaScript is the most common speed factor that every site encounters. Unused JavaScript files are the pinpoint of the WordPress users which deteriorate website performance and ultimately result […]<\/p>\n","protected":false},"author":2,"featured_media":2448,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[362,7],"tags":[2834,2835,2823,2819,2827,2830,2829,2831,2826,2820,2832,2822,2821,2833,2828,2825,2824],"_links":{"self":[{"href":"https:\/\/basicwebguide.com\/wp-json\/wp\/v2\/posts\/2403"}],"collection":[{"href":"https:\/\/basicwebguide.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/basicwebguide.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/basicwebguide.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/basicwebguide.com\/wp-json\/wp\/v2\/comments?post=2403"}],"version-history":[{"count":10,"href":"https:\/\/basicwebguide.com\/wp-json\/wp\/v2\/posts\/2403\/revisions"}],"predecessor-version":[{"id":2450,"href":"https:\/\/basicwebguide.com\/wp-json\/wp\/v2\/posts\/2403\/revisions\/2450"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/basicwebguide.com\/wp-json\/wp\/v2\/media\/2448"}],"wp:attachment":[{"href":"https:\/\/basicwebguide.com\/wp-json\/wp\/v2\/media?parent=2403"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/basicwebguide.com\/wp-json\/wp\/v2\/categories?post=2403"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/basicwebguide.com\/wp-json\/wp\/v2\/tags?post=2403"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}