示例#1
0
 public function compressJavascript()
 {
     if ($this->_context->_optimize == 2 || $this->_context->_optimize == 3 || $this->_context->_optimize == 4) {
         // don't create if files have exists
         if (!JFile::exists($this->_cacheJSFile)) {
             Avatar::import('core.libraries.minify.jsmin');
             $path = dirname(JPATH_ROOT);
             $output = '';
             foreach ($this->_scripts as $script) {
                 $source = @file_get_contents($path . $script);
                 $output .= JSMin::minify($source);
             }
             file_put_contents($this->_cacheJSFile, $output);
         }
         $this->_jtemplate->setHeadData(array('scripts' => array($this->_cacheJSFileURI => array('mime' => 'text/javascript', 'defer' => false, 'async' => false, 'media' => false, 'attribs' => false))));
     }
 }
示例#2
0
 /**
  * optimize the css and js
  */
 public function optimize()
 {
     if ($this->_optimize) {
         Avatar::import('core.helpers.compress');
         $compressObj = new AvatarCompress($this);
         $compressObj->compress();
     }
 }