How to overright plugin file's js in child theme

Forums WordPressHow to overright plugin file's js in child theme
Staff asked 3 years ago

Answers (1)

Add Answer
Staff answered 3 years ago

To override the plugin js files in the child theme you can follow the same process as described in the above step.

But we can use another way to achieve this which is to deregister the old script and then enqueue the new one with the same handler.

I have tried this thing with an inquiry plugin js files.

add_action('wp_enqueue_scripts', 'enquiry_cart_scripts');
function enquiry_cart_scripts() {
  wp_dequeue_script( 'gmwqp-script' );
  wp_deregister_script( 'gmwqp-script' );
  wp_enqueue_script( 'gmwqp-script',  MY_CHILD_URI . 'assets/js/enquiry.js', array('jquery'), '', true );
}

 

Subscribe

Select Categories