DEV Community

Cover image for How to remove extra javascripts wordpress?
Chetan Rohilla
Chetan Rohilla

Posted on • Updated on • Originally published at

How to remove extra javascripts wordpress?

Some times we need to remove some javascript from our wordpress website or blog to speed up our website. Here below is a trick which you can use to remove unused js from your wordpress website.

First of all you have to find the javascript file which you want to remove and to find this open your webpage in google chrome and press ctrl+u to view the source code of the webpage, then find the script tag of js file and there you will see the id in the script tag and this is what you need to remove the js. Now paste the code given below in your functions.php file located at root_directory_path/wp-content/themes/your_theme/functions.php

And we have used here two wordpress core functions wp_dequeue_script and wp_deregister_script.

Here ‘woocommerce’ is the id of the script tag which you have found in source code of webpage.

function wra_filter_scripts(){

    if( is_home() == true || is_single() == true ){




add_action('wp_print_scripts', 'wra_filter_scripts', 100000);
add_action('wp_print_footer_scripts',  'wra_filter_scripts', 100000);
Enter fullscreen mode Exit fullscreen mode

Please like share subscribe and give positive feedback to motivate me to write more for you.

For more tutorials please visit my website.

Happy Coding:)

Top comments (1)

garima2808 profile image

Hello Chetan! Are you open to new job opportunities?