You are here

function _boost_copy_js_files in Boost 6

Extract javascript filenames from html and copy them & their children.

Parameters

$js_files: Array containing all javascript filenames.

1 call to _boost_copy_js_files()
boost_cache_css_js_files in ./boost.module
Cache css and or js files.

File

./boost.module, line 4939
Provides static file caching for Drupal text output. Pages, Feeds, ect...

Code

function _boost_copy_js_files($js_files) {

  //copy files
  foreach ($js_files as $js_file) {

    // Strip extension from filename
    $js_file = _boost_kill_file_extension($js_file);
    if (file_exists($js_file . '.js')) {
      $src = $js_file . '.js';
      $dest = BOOST_PERM_FILE_PATH . '/' . $src . BOOST_PERM_CHAR . BOOST_JS_EXTENSION;
      _boost_copy_file($src, $dest);
    }
    if (file_exists($js_file . '.js.gz')) {
      $src = $js_file . '.js.gz';
      $dest = BOOST_PERM_GZIP_FILE_PATH . '/' . $js_file . '.js' . BOOST_PERM_CHAR . BOOST_JS_EXTENSION . BOOST_GZIP_EXTENSION;
      _boost_copy_file($src, $dest);
    }
    elseif (BOOST_GZIP && file_exists($js_file . '.js')) {
      $src = $js_file . '.js';
      $dest = BOOST_PERM_GZIP_FILE_PATH . '/' . $src . BOOST_PERM_CHAR . BOOST_JS_EXTENSION . BOOST_GZIP_EXTENSION;
      _boost_gz_copy_file($src, $dest);
    }
    if (file_exists($js_file . '.jsmin.js')) {
      $src = $js_file . '.jsmin.js';
      $dest = BOOST_PERM_FILE_PATH . '/' . $src . BOOST_PERM_CHAR . BOOST_JS_EXTENSION;
      _boost_copy_file($src, $dest);
    }
    if (file_exists($js_file . '.jsmin.js.gz')) {
      $src = $js_file . '.jsmin.js.gz';
      $dest = BOOST_PERM_GZIP_FILE_PATH . '/' . $js_file . '.jsmin.js' . BOOST_PERM_CHAR . BOOST_JS_EXTENSION . BOOST_GZIP_EXTENSION;
      _boost_copy_file($src, $dest);
    }
    elseif (BOOST_GZIP && file_exists($js_file . '.jsmin.js')) {
      $src = $js_file . '.jsmin.js';
      $dest = BOOST_PERM_GZIP_FILE_PATH . '/' . $src . BOOST_PERM_CHAR . BOOST_JS_EXTENSION . BOOST_GZIP_EXTENSION;
      _boost_gz_copy_file($src, $dest);
    }
  }
}