Override module javascript file in theme or custom module
hook_js_alter() allows you to modify any JS before it is written to the page.
The documentation includes a snippet to replace a core file with an alternate from a module:

function hook_js_alter(&amp;$javascript) {
  // Swap out jQuery to use an updated version of the library.
  $javascript['misc/jquery.js']['data'] = drupal_get_path('module', 'jquery_update') . '/jquery.js';
}