You are here

function minifyjs_update_scripts in Minify JS 8.2

Same name and namespace in other branches
  1. 8 minifyjs.module \minifyjs_update_scripts()
  2. 7 minifyjs.module \minifyjs_update_scripts()

Update script.

Helper function to change array key, without changing its order.

Parameters

array $scripts: The scripts that are attached to the page.

string $existing: The existing file uri.

string $new: The new file uri.

1 call to minifyjs_update_scripts()
minifyjs_js_alter in ./minifyjs.module
Implements hook_js_alter().

File

./minifyjs.module, line 115
Hooks and functions for the minifyjs module.

Code

function minifyjs_update_scripts(array &$scripts, $existing, $new) {
  $keys = array_keys($scripts);
  $index = array_search($existing, $keys, TRUE);
  if ($index !== FALSE) {
    $keys[$index] = $new;
    $scripts = array_combine($keys, $scripts);
  }
}