• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP JSMin类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中JSMin的典型用法代码示例。如果您正苦于以下问题:PHP JSMin类的具体用法?PHP JSMin怎么用?PHP JSMin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了JSMin类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: minify

 /**
  * Minify Javascript.
  *
  * @param string $js Javascript to be minified
  * @return string
  */
 public static function minify($js, $pic = false)
 {
     $jsmin = new JSMin($js, $pic);
     $min = $jsmin->min();
     unset($jsmin);
     return $min;
 }
开发者ID:kidaa30,项目名称:redcat,代码行数:13,代码来源:JSMin.php


示例2: minify

 function minify($js)
 {
     $jsmin = new JSMin($js);
     $output = $jsmin->min();
     if ($output === false) {
         return $js;
     }
     return $output;
 }
开发者ID:howardlei82,项目名称:IGSM-Website,代码行数:9,代码来源:jsmin.php


示例3: get_js_html

 private function get_js_html($cachefile)
 {
     if (Configure::read('debug') > 0) {
         $ret = "";
         foreach ($this->libs['js'] as $lib) {
             $ret .= $this->Javascript->link($lib);
         }
         return $ret;
     }
     if (file_exists($this->cachePath['js'] . '/' . $cachefile)) {
         return $this->Javascript->link($cachefile);
     }
     // Get the content
     $file_content = '';
     foreach ($this->libs['js'] as $lib) {
         $file_content .= "\n\n" . file_get_contents($this->basePath['js'] . '/' . $lib);
     }
     // If compression is enable, compress it !
     if ($this->__options['js']['enableCompression']) {
         App::import('Vendor', 'jsmin/jsmin');
         $file_content = trim(JSMin::minify($file_content));
     }
     // Get inline code if exist
     // Do it after jsmin to preserve variable's names
     if (!empty($this->inline_code['js'])) {
         foreach ($this->inline_code['js'] as $inlineJs) {
             $file_content .= "\n\n" . $inlineJs;
         }
     }
     if ($fp = fopen($this->cachePath['js'] . '/' . $cachefile, 'wb')) {
         fwrite($fp, $file_content);
         fclose($fp);
     }
     return $this->Javascript->link($cachefile);
 }
开发者ID:acerato,项目名称:cntcetp,代码行数:35,代码来源:combinator.php


示例4: pack

 public static function pack($compression = 'none', $code = '')
 {
     if (!$code) {
         throw new PHPJS_Exception('No code to pack');
         return false;
     }
     switch ($compression) {
         case 'packed':
             require_once dirname(__FILE__) . '/Pack/class.JavaScriptPacker.php';
             $packer = new JavaScriptPacker($code, 'Normal', true, false);
             $code = $packer->pack();
             break;
         case 'minified':
             require_once dirname(__FILE__) . '/Pack/jsmin.php';
             $code = JSMin::minify($code);
             break;
         case 'none':
             break;
         default:
             throw new PHPJS_Exception('No such packer: "' . $compression . '"');
             return false;
             break;
     }
     return '// Compression: ' . $compression . "\n\n" . $code;
 }
开发者ID:primeminister,项目名称:phpjs,代码行数:25,代码来源:Pack.php


示例5: compile

 function compile()
 {
     $output = $this->CI->output->get_output();
     // get <head> contents
     $matches = array();
     preg_match('#<head>(.*?)<\\/head>#si', $output, $matches);
     // head contents
     $head = $matches[1];
     // get JS includes via <script> references
     preg_match_all('#<script(.*?)src="(.*?)"(.*?)>(.*?)<\\/script>#si', $head, $matches);
     $js_includes = $matches[2];
     // delete non-local includes
     foreach ($js_includes as $key => $script) {
         if (strpos($script, '//') !== FALSE and strpos($script, $this->CI->config->item('base_url')) === FALSE) {
             // this script is external (has "//") and it's not just a domain reference to this site
             unset($js_includes[$key]);
         }
     }
     if (!empty($js_includes)) {
         $this->load->library('JSMin');
         // minify!
         $js_compiled = '';
         foreach ($js_includes as $script) {
             // get the file
             $js_compiled .= JSMin::minify($script);
         }
     }
     // TODO:
     // - load the files for minification
     //		- this includes using the base_href tag if one exists, otherwise loading paths relative to the domain or
     //		  using the full script URL if it's in that format
     // - replace old <script> references with one big reference
     // return the output
 }
开发者ID:Rotron,项目名称:hero,代码行数:34,代码来源:head_compile.php


示例6: Amango_Asset

/**
 * Emoji表情解析
 * @return string
 * @param [string] [$str] [将字符串中的[E537] 这类的emoji标签【仅支持SB Unicode】转化为Unicode值 ]
 *        emoji标签 详情网址: http://punchdrunker.github.io/iOSEmoji/table_html/index.html
 */
function Amango_Asset($options, $type = 'js')
{
    $path = './Data/js_cache/' . md5($options) . '.js';
    if (!is_file($path)) {
        //静态资源地址
        $files = explode(',', $options);
        $content = '';
        foreach ($files as $val) {
            $content .= file_get_contents('.' . str_replace(__ROOT__, '', $val));
        }
        import('Common.ORG.JSMin');
        $JSMin = new JSMin();
        file_put_contents($path, $JSMin->minify($content));
    }
    echo '<script type="text/javascript" src="' . $path . '?' . time() . '"></script>';
}
开发者ID:wmk223,项目名称:amango_V3,代码行数:22,代码来源:laravel.php


示例7: minify

 public function minify($inPath, $outPath)
 {
     $extension = $this->getExtension($inPath);
     echo basename($inPath) . ' -> ' . basename($outPath) . '...';
     $inText = file_get_contents($inPath);
     if ($inText === false) {
         $this->error("Unable to open file {$inPath} for reading.");
         exit(1);
     }
     $outFile = fopen($outPath, 'w');
     if (!$outFile) {
         $this->error("Unable to open file {$outPath} for writing.");
         exit(1);
     }
     switch ($extension) {
         case 'js':
             $outText = JSMin::minify($inText);
             break;
         default:
             $this->error("No minifier defined for extension \"{$extension}\"");
     }
     fwrite($outFile, $outText);
     fclose($outFile);
     echo " ok\n";
 }
开发者ID:rocLv,项目名称:conference,代码行数:25,代码来源:minify.php


示例8: minify

 public function minify()
 {
     if ($this->contentType != 'text/css') {
         G::LoadThirdParty('jsmin', 'jsmin');
         $this->content = JSMin::minify($this->content);
     }
 }
开发者ID:emildev35,项目名称:processmaker,代码行数:7,代码来源:class.helper.php


示例9: jsAction

 /**
  * Минификация яваскриптов
  * 
  * @return void
  */
 public function jsAction()
 {
     $this->_response->setHeader('Content-Type', 'text/javascript', true);
     if (isset($this->_params['files'])) {
         $files = explode(',', $this->_params['files']);
         foreach ($files as $key => $file) {
             $file = $this->_jsdir . trim($file) . '.js';
             if (file_exists($file)) {
                 $files[$key] = $file;
             }
         }
         if (!empty($files)) {
             $cacheid = 'minify_js_' . md5(implode(',', $files));
             $this->_cache->setMasterFiles($files);
             if ($this->_cache->test($cacheid)) {
                 $this->_response->setBody($this->_cache->load($cacheid));
             } else {
                 require_once 'Phorm/Plugin/jsmin.php';
                 $str = '';
                 foreach ($files as $file) {
                     $str .= file_get_contents($file) . PHP_EOL;
                 }
                 $js = JSMin::minify($str);
                 $this->_cache->save($js, $cacheid);
                 $this->_response->setBody($js);
             }
         }
     }
 }
开发者ID:ei-grad,项目名称:phorm,代码行数:34,代码来源:Minify.php


示例10: minifyJs

 public static function minifyJs(array $jsFiles)
 {
     if (true) {
         foreach ($jsFiles as $path) {
             $pathInfo = pathinfo($path);
             if (strpos($path, 'js/xenforo/') !== false) {
                 // ignore xenforo files
                 continue;
             }
             $dirName = $pathInfo['dirname'];
             $realDirName = realpath($dirName);
             $fullDirName = realpath($realDirName . '/full');
             $baseName = $pathInfo['basename'];
             $minPath = $realDirName . '/' . $baseName;
             $fullPath = $fullDirName . '/' . $baseName;
             if (file_exists($fullPath) and (!file_exists($minPath) or filemtime($fullPath) > filemtime($minPath))) {
                 $fullContents = file_get_contents($fullPath);
                 if (strpos($fullContents, '/* no minify */') === false) {
                     require_once dirname(__FILE__) . '/../Lib/jsmin-php/jsmin.php';
                     $minified = JSMin::minify($fullContents);
                 } else {
                     // the file requested not to be minify... (debugging?)
                     $minified = $fullContents;
                 }
                 self::writeFile($minPath, $minified, false, false);
             }
         }
     }
 }
开发者ID:maitandat1507,项目名称:DevHelper,代码行数:29,代码来源:File.php


示例11: moodbile_performance_minify_js

function moodbile_performance_minify_js($js)
{
    global $CFG;
    require_once $CFG['basepath'] . 'misc/jsmin.php';
    $js = JSMin::minify($js);
    return $js;
}
开发者ID:ratheep,项目名称:moodbile,代码行数:7,代码来源:performance.lib.php


示例12: minifyjs

 /** 
  * minify js and return js link
  * if minify is disabled: return direct js links
  *
  * @return string with html tag
  * @param array $javascripts with js files
  */
 public function minifyjs($javascripts)
 {
     if (Zend_Registry::get('config')->cache->enable == 1 && Zend_Registry::get('config')->cache->minifyjs == 1) {
         // check file
         $target = Zend_Registry::get('config')->pub->path . 'javascript/' . Zend_Registry::get('config')->cache->minifiedjsfile;
         $targeturl = 'javascript/' . Zend_Registry::get('config')->cache->minifiedjsfile;
         if (file_exists($target)) {
             return "<script type=\"text/javascript\" src=\"" . $targeturl . "\"></script>\n";
         }
         // load and minify files
         $all = "";
         foreach ($javascripts as $js) {
             $jscontent = file_get_contents(Zend_Registry::get('config')->pub->path . $js);
             $jscontent = JSMin::minify($jscontent);
             $all = $all . "\n\n// " . $js . "\n" . $jscontent;
         }
         file_put_contents($target, $all);
         return "<script type=\"text/javascript\" src=\"" . $targeturl . "\"></script>\n";
     } else {
         $ret = "";
         foreach ($javascripts as $js) {
             $ret = $ret . "<script type=\"text/javascript\" src=\"" . $js . "\"></script>\n";
         }
         return $ret;
     }
 }
开发者ID:google-code-backups,项目名称:rsslounge,代码行数:33,代码来源:Minifyjs.php


示例13: addjstext

function addjstext($output, $minify = true)
{
    if ($minify == true && (MINIFY == true || MINIFY == 1)) {
        $output = JSMin::minify($output);
    }
    return $output;
}
开发者ID:richpanzer,项目名称:ODS-Mobile---Supplement,代码行数:7,代码来源:functions.php


示例14: beforeAction

 public function beforeAction($action)
 {
     $base = Cshop::$rootpath;
     $jsfilename = $base . "/static/cache/final.js";
     if (!file_exists($jsfilename)) {
         $filename = $base . "/static/js/jquery.js";
         $js = file_get_contents($filename);
         $filename = $base . "/static/js/jquery-ui.js";
         $js .= file_get_contents($filename);
         $filename = $base . "/static/js/jquery.mousewheel.js";
         $js .= file_get_contents($filename);
         $filename = $base . "/static/js/perfect-scrollbar.js";
         $js .= file_get_contents($filename);
         $filename = $base . "/static/js/jquery.placeholder.js";
         $js .= file_get_contents($filename);
         $filename = $base . "/static/js/jquery.noty.packaged.min.js";
         $js .= file_get_contents($filename);
         $filename = $base . "/static/js/script.js";
         $js .= file_get_contents($filename);
         $js = JSMin::minify($js);
         file_put_contents($jsfilename, $js);
     }
     $cssfilename = $base . "/static/cache/final.css";
     if (!file_exists($cssfilename)) {
         $filename = $base . "/static/css/style.css";
         $css = file_get_contents($filename);
         $filename = $base . "/static/css/perfect-scrollbar.css";
         $css .= file_get_contents($filename);
         $minify = new CSSmin();
         $css = $minify->run($css, true);
         file_put_contents($cssfilename, $css);
     }
     return parent::beforeAction($action);
 }
开发者ID:aliazizi,项目名称:CShop,代码行数:34,代码来源:Controller.php


示例15: getJsContents

 /**
  * override method: get content of css files
  */
 function getJsContents($files, $isCompressed = true, $isYUI = false)
 {
     $contents = "/**ICE-ENGINE-JS**/";
     foreach ($files as $file) {
         $subpath = str_replace('/', DS, $file);
         $fullpath = JPATH_ROOT . DS . $subpath;
         //	$basepath = preg_replace( '/^\//', '', dirname($files2[$key]) );
         $contentFile = '';
         if (preg_match('/\\.php/', $file)) {
             $contentFile = @file_get_contents(JURI::base() . str_replace("&amp;", "&", $file));
         } else {
             if (file_exists($fullpath)) {
                 // get Content Of File;
                 $contentFile = @file_get_contents($fullpath);
             }
         }
         if ($contentFile) {
             $contents .= "/** '.{$subpath}.' **/\t";
             $contents .= $contentFile;
         }
     }
     if ($isCompressed) {
         if ($isYUI) {
             $app =& JFactory::getApplication();
             Minify_YUICompressor::$jarFile = dirname(__FILE__) . DS . 'Minify' . DS . 'yuicompressor-2.4.6.jar';
             Minify_YUICompressor::$tempDir = $app->getCfg("tmp_path");
             $contents = Minify_YUICompressor::minifyJs($contents, array('nomunge' => true, 'line-break' => 1000));
         } else {
             $contents = JSMin::minify($contents);
         }
     }
     return $contents;
 }
开发者ID:optimosolution,项目名称:marhk,代码行数:36,代码来源:minify.php


示例16: combine

 /**
  * Combine multiple text assets into a single file for better http performance this
  * method generates a new cache file with every symfony cc you can override the cache
  * by adding ?clearassetcache=1 to the page request.
  *
  * @param type      string css or js
  * @param namespace string the combined file namespace (eg. module+action names)
  * @param response  object the sfWebResponse instance
  * @return          string the url for the combiner service
  */
 public function combine($type, $namespace, sfWebResponse $response)
 {
     //configure the combiner
     $type = $type === 'css' ? 'css' : 'js';
     $fullname = $type === 'css' ? 'Stylesheets' : 'Javascripts';
     $response_getter = 'get' . $fullname;
     $namespace = StreemeUtil::slugify($namespace);
     //integrate into symfony's asset globals
     sfConfig::set(sprintf('symfony.asset.%s_included', strtolower($fullname)), true);
     //build the cache filename - this file will be regenerated on a symfony cc
     $path = sprintf('%s/combine/%s/', sfConfig::get('sf_cache_dir'), $type);
     $filename = sprintf('%s.%s', $namespace, $type);
     // you can force a cache clear by passing ?clearassetcache=1 to any template
     if (!is_readable($path . $filename) || @$_GET['clearassetcache'] == 1) {
         //build one file of all of the css or js files
         $file_content = '';
         //load vendor libraries for minifying assets
         require_once sfConfig::get('sf_lib_dir') . '/vendor/jsmin/jsmin.php';
         require_once sfConfig::get('sf_lib_dir') . '/vendor/cssmin/cssmin.php';
         foreach ($response->{$response_getter}() as $file => $options) {
             if ($type === 'css') {
                 $file_content .= CSSMin::minify(file_get_contents(sfConfig::get('sf_web_dir') . $file));
             } else {
                 $file_content .= JSMin::minify(file_get_contents(sfConfig::get('sf_web_dir') . $file));
             }
         }
         //this file resides in the cache and requires wide permissions for both cli and apache users
         @umask(00);
         @mkdir($path, 0777, true);
         file_put_contents($path . $filename, $file_content);
     }
     return sprintf('/service/combine/%s/%s', $type, str_replace('-', '_', $namespace));
 }
开发者ID:Alenpiera,项目名称:streeme,代码行数:43,代码来源:combineFiles.class.php


示例17: js

 /**
  * Include Javascript files
  *
  * @param array $files
  * @return string HTML JavaScript file include
  */
 function js($files = array())
 {
     // Output links to normal uncompressed files if developing
     if (Configure::read('debug') > 0) {
         return $this->Javascript->link($files);
     }
     // Create new packed files if not up to date
     $jsBaseName = 'cache.js';
     $jsFilePath = "{$this->_jsDir}{$jsBaseName}";
     // Create the cache if it doesn't exist
     if (!file_exists($jsFilePath)) {
         $save = '';
         // Get content of all files
         foreach ($files as &$file) {
             $file = str_replace('/', DS, $file);
             // replace URL dash with file system dash
             $ext = substr(strrchr($file, '.'), 1);
             // Add .js file extension if using short file name
             if ($ext !== '.js') {
                 $file = "{$file}.js";
             }
             $path = "{$this->_jsDir}{$file}";
             // Add file content
             $save .= file_get_contents($path);
         }
         // Minify the JavaScript content
         $save = JSMin::minify($save);
         $file = fopen($jsFilePath, 'w');
         fwrite($file, $save);
         fclose($file);
     }
     return $this->Javascript->link($jsBaseName);
 }
开发者ID:uuking,项目名称:wildflower,代码行数:39,代码来源:packager.php


示例18: run

 public static function run($mode, $browser = 'cross')
 {
     self::$buildDir = dirname(__FILE__) . DIRECTORY_SEPARATOR;
     self::$browser = $browser;
     chdir(self::$buildDir . '..');
     $release = $mode == 'release' || file_exists(self::gitHead) && preg_match('!/master$!', file_get_contents(self::gitHead));
     $buildMode = $release ? 'Release' : 'Dev';
     echo "{$buildMode} mode\n";
     $buildTime = date('Y-m-d H:i:s');
     $buildNumber = (int) @file_get_contents(self::buildFile);
     if ($release) {
         // increase release build number for extensions
         /* Now we can't increate it automatically. Do this manually
         			$buildNumber++;
         			file_put_contents(self::buildFile, $buildNumber);
         			*/
         echo "Build number: {$buildNumber}\n";
     }
     $code = strtr(file_get_contents(self::core), array('// @corelibs@' => self::sourcesByList('corelibs.txt', 'core/'), '// @contentModules@' => self::sourcesByList('contentModules.txt', 'content/'), '// @modules@' => self::sourcesByList('modules.txt', 'modules/'), '@buildTime@' => $buildTime, '@buildMode@' => $buildMode, '@buildNumber@' => $buildNumber, '// @jQuery@' => file_get_contents('core/libs/jquery.js')));
     if ($release) {
         file_put_contents(self::revisor, json_encode(array('buildTime' => $buildTime)));
         echo "Compressing...\n";
         require_once self::$buildDir . 'jsmin.php';
         $parts = explode('==/UserScript==', $code);
         $parts[1] = JSMin::minify($parts[1]);
         $code = implode("==/UserScript==\n", $parts);
         $output = self::output;
     } else {
         $output = self::devOutput;
     }
     file_put_contents($output, $code);
     echo "done.\n";
     echo "Now install " . realpath($output) . " script into your browser.\n";
 }
开发者ID:adequator,项目名称:dirty-on-steroids,代码行数:34,代码来源:d3merge.php


示例19: getCompressed

 public static function getCompressed()
 {
     ob_end_clean();
     header('Content-Encoding: none');
     if (!array_key_exists('file', $_GET)) {
         die;
     }
     $filename = PATH_ABS_ROOT . ltrim($_GET['file'], '/');
     $contents = file_get_contents($filename);
     $etag = sha1($filename . $contents);
     $ext = pathinfo($filename, PATHINFO_EXTENSION);
     switch ($ext) {
         case 'js':
             $type = 'text/javascript';
             $contents = JSMin::minify($contents);
             break;
         case 'css':
             $type = 'text/css';
             //$contents = CssMin::minify($contents);
             break;
         default:
             $type = 'text/html';
     }
     //		utopia::Cache_Check($etag,$type);
     utopia::Cache_Output($contents, $etag, $type);
     die($contents);
 }
开发者ID:OptimalInternet,项目名称:uCore,代码行数:27,代码来源:static_ajax.php


示例20: load

    protected function load($path)
    {
        if (isset($this->loaded[$path])) {
            return '';
        }
        if (!file_exists($path)) {
            die("ERROR: Couldn't load {$path} required from {$this->currentInput}\n");
        }
        echo "loading {$path} \n";
        $this->loaded[$path] = true;
        $this->currentInput = $path;
        $code = file_get_contents($path);
        $this->bytesIn += strlen($code);
        $this->fileCount++;
        if ($this->format & self::MINIFIED) {
            $code = trim(JSMin::minify($code));
        }
        // Naively probe the file for 'ig.module().requires().defines()' code;
        // the 'requries()' part will be handled by the regexp callback
        $this->definesModule = false;
        $code = preg_replace_callback('/ig\\s*
				\\.\\s*module\\s*\\((.*?)\\)\\s*
				(\\.\\s*requires\\s*\\((.*?)\\)\\s*)?
				\\.\\s*defines\\s*\\(
			/smx', array($this, 'loadCallback'), $code);
        // All files should define a module; maybe we just missed it? Print a
        // friendly reminder :)
        if (!$this->definesModule) {
            echo "WARNING: file {$path} seems to define no module!\n";
        }
        return $code;
    }
开发者ID:lwnexgen,项目名称:ld34,代码行数:32,代码来源:bake.php



注:本文中的JSMin类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP JSMinPlus类代码示例发布时间:2022-05-23
下一篇:
PHP JSFactory类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap