A better way to override plugin’s JS files?

Extending the above comment:

Directly changing the files of the plugin or theme is not a good practice as once the plugin/theme is updated, you will loose the changes. Instead use child theme in case of themes and hook to required actions in case of plugins.

In your case since you are only changing the script in plugin and they might have enqueued(they should be) with wp_enqueue_script hooked to wp_enqueue_scripts. You can dequeue that script using wp_dequeue_script all you have to do is findout the script handle from the original plugin. Then you need to enqueue the changed script.

Leave a Comment