Compress html

if this is the code

  public function compressorCodeJs($template, $files, $compressor_status, $http_server) {
      if($compressor_status == 1 && is_writable('catalog/view/theme/' . $template . '/js')) {
          $file_cache = 'catalog/view/theme/' . $template . '/js/cache_js.js';
          $cache_life = 3600;
          if(!file_exists($file_cache) or (time() - filemtime($file_cache) >= $cache_life)){
              $buffer = "";
              foreach($files as $file) {
                  $buffer .= file_get_contents($http_server . $file);
            $buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
            $buffer = str_replace(': ', ':', $buffer);
              file_put_contents($file_cache, $buffer);  
          return '<script type="text/javascript" src="catalog/view/theme/' . $template . '/js/cache_js.js"></script>';
      } else {
          $output = '';
          foreach($files as $file) {
              $output .= '<script type="text/javascript" src="' . $file . '"></script>';
              $output .= "\n";
          return $output;

what will html compressor be?

So basically, it does two things:
Run a preg_replace
Remove spaces after a colon.

The preg regex is looking for a slash, followed by a asterisk, followed by any number of non-asterisks, followed by one or more asterisks; followed by any number of subpatterns of something other than a slash, followed by any number of somethings that isnt an asterisk, folllowed by one or more asterisk, and finally a slash.
It’ll take anything it finds that matches that pattern, and remove it.

I would assume that is looking to slice out any comment blocks. (/* This is a comment */)

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.