Esempio n. 1
0
 /**
  * Compress inline JS code found in a HTML file.
  * Only por internal usage.
  * @access private
  */
 public static function _compress_inline_js($js)
 {
     if (self::_has_mark($js)) {
         return $js;
     } else {
         return Tinyfier_JS_Tool::process($js, self::$_settings['js'] + array('external_services' => self::$_settings['external_services']));
     }
 }
Esempio n. 2
0
 //Process source code
 try {
     require $autoloader_path;
     if ($type == 'js') {
         //Combine, then compress
         //Combine
         $source = array();
         foreach ($files as $url_path => $absolute_path) {
             if ($debug) {
                 $source[] = "\n\n\n/* {$url_path} */\n\n\n";
             }
             $source[] = file_get_contents($absolute_path) . "\n";
         }
         //Compress
         $source = implode(';', $source);
         $source = Tinyfier_JS_Tool::process($source, array('pretty' => $debug, 'gclosure' => strlen($source) > 750 && !$debug));
     } elseif ($type == 'css' || $type == 'less') {
         //Process and compress, then combine
         //Process and compress
         $source = array();
         foreach ($files as $url_path => $absolute_path) {
             if ($debug) {
                 $source[] = "\n\n\n/* {$url_path} */\n\n\n";
             }
             $source[] = Tinyfier_CSS_Tool::process_file($absolute_path, array('url_path' => $url_path, 'cache_path' => $cache_dir, 'compress' => !$debug, 'data' => $vars, 'optimize_images' => !$debug && $optimize_images));
         }
         //Combine
         $source = implode("\n", $source);
     } else {
         header('HTTP/1.0 400 Bad Request');
         die('Invalid source type');