skip to Main Content

A plugin vendor I’m getting support from recently suggested that if I didn’t want a certain Javascript file within the plugin to be enqueued, I should go into the plugin’s files and comment out the enqueueing. However, this will potentially have to be repeated each time I update the plugin. Is there a way to un-enqueue a plugin’s script from functions.php in my child theme so that the change will "stick"?

2

Answers


  1. function wp_dequeue_script( $handle ) {
        _wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle );
     
        wp_scripts()->dequeue( $handle );
    }
    
    Login or Signup to reply.
  2. Yes there is, the native WordPress function is called wp_dequeue_script.

    Remove a previously enqueued script.

    @see https://developer.wordpress.org/reference/functions/wp_dequeue_script/

    Example

    add_action( 'init', function () {
        wp_dequeue_script( 'jquery-ui-core' );
    } );
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search