You are here

function advagg_js_compress_configuration in Advanced CSS/JS Aggregation 7.2

Generate the js compress configuration.

Return value

array Array($options, $description, $compressors, $functions).

4 calls to advagg_js_compress_configuration()
advagg_js_compress_admin_settings_form in advagg_js_compress/advagg_js_compress.admin.inc
Form builder; Configure advagg settings.
advagg_js_compress_do_it in advagg_js_compress/advagg_js_compress.advagg.inc
Compress a JS string.
advagg_js_compress_get_enabled_compressors in advagg_js_compress/advagg_js_compress.advagg.inc
Get a list of enabled compressors.
advagg_js_compress_test_file in advagg_js_compress/advagg_js_compress.module
Test a file, making sure it is compressible.

File

advagg_js_compress/advagg_js_compress.module, line 398
Advanced CSS/JS aggregation js compression module.

Code

function advagg_js_compress_configuration() {

  // Set the defaults.
  $description = '';
  $options = array(
    0 => t('Disabled'),
    1 => t('JSMin+ ~1300ms'),
  );
  if (function_exists('jsmin')) {
    $options[3] = t('JSMin ~2ms');
    $description .= t('JSMin is the very fast C complied version. Recommend using it.');
  }
  else {
    if (!defined('PHP_VERSION_ID') || constant('PHP_VERSION_ID') < 50310) {
      $link = 'http://www.ypass.net/software/php_jsmin/';
    }
    else {
      $link = 'https://github.com/sqmk/pecl-jsmin/';
    }
    $description .= t('You can use the much faster C version of JSMin (~2ms) by installing the <a href="@php_jsmin">JSMin PHP Extension</a> on this server.', array(
      '@php_jsmin' => $link,
    ));
  }

  // Add in JShrink and JSqueeze if using php 5.3 or higher.
  if (defined('PHP_VERSION_ID') && constant('PHP_VERSION_ID') >= 50300) {
    $options += array(
      4 => t('JShrink ~1000ms'),
      5 => t('JSqueeze ~600ms'),
    );
  }
  $compressors = array(
    1 => 'jsminplus',
    2 => 'packer',
  );
  if (function_exists('jsmin')) {
    $compressors[3] = 'jsmin';
  }
  if (defined('PHP_VERSION_ID') && constant('PHP_VERSION_ID') >= 50300) {
    $compressors += array(
      4 => 'jshrink',
      5 => 'jsqueeze',
    );
  }
  $functions = array(
    1 => 'advagg_js_compress_jsminplus',
    2 => 'advagg_js_compress_jspacker',
    3 => 'advagg_js_compress_jsmin',
    4 => 'advagg_js_compress_jshrink',
    5 => 'advagg_js_compress_jsqueeze',
  );

  // Allow for other modules to alter this list.
  $options_desc = array(
    $options,
    $description,
  );

  // Call hook_advagg_js_compress_configuration_alter().
  drupal_alter('advagg_js_compress_configuration', $options_desc, $compressors, $functions);
  list($options, $description) = $options_desc;
  return array(
    $options,
    $description,
    $compressors,
    $functions,
  );
}