javascriptwordpresswordpress-theming

Wordpress remove_action and wp_deregister_script don't work


I try to remove script from the footer in my Wordpress page. Here is the end of my footer:

<?php remove_action('wp_footer','woodmart-theme-js-after');?>
<?php wp_deregister_script('woodmart-theme-js-after');?>
<?php do_action( 'woodmart_before_wp_footer' ); ?>
<?php wp_footer(); ?>

Here is the script. It has id, but not src. I don't know does it matter or not.

Scrin of script

I wasn't able to find the code of this script to rewrite it. Used search in visual studio code. It's strange. I also tried to put remove_action in different places of code. Nothing works. Need help


Solution

  • Standard function for scripts deregisters, needs to be included in functions.php theme file.

    function remove_woodmart_footer_script() {
      
        // If there's a specific script to deregister
        wp_dequeue_script('woodmart-theme-js');
        wp_deregister_script('woodmart-theme-js');
    }
    add_action('wp_enqueue_scripts', 'remove_woodmart_footer_script');