Asp.Net浣跨敤Yahoo.Yui.Compressor.dll鍘嬬缉Js|Css

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Asp.Net浣跨敤Yahoo.Yui.Compressor.dll鍘嬬缉Js|Css相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/blog' title='blog'>blog   sax   lte   鑰屼笖   鑷繁瀹炵幇   rar   search   yahoo   http   

缃戜笂鍘嬬缉css鍜宩s宸ュ叿寰堝锛屼絾鍦ㄦ垜浠殑绯荤粺涓€绘湁鐗规畩鐨勫湴鏂广€備篃璁镐綘浼氳寰楃敤绗笁鏂圭殑鍘嬬缉宸ュ叿寰堥夯鐑︺€傛垜灏遍亣鍒颁簡杩欐牱闂锛屾垜涓嶆兂鍦ㄦ湰鍦板帇缂?鍙兂鏇存柊鍒版湇鍔″櫒涓婂幓鍘嬬缉锛屾湇鍔″櫒鍘嬬缉涔熶笉鐢ㄥ浠戒箣绫荤殑鎿嶄綔銆備簬鏄垜灏辨兂鐫€鑷繁瀹炵幇鍘嬬缉宸ュ叿銆?/p>

鍒濇闇€姹傚涓嬶細 

  • 浣跨敤Yahoo.Yui.Compressor 2.0鐗堟湰
  • 鍙缃戠珯鐩綍涓嬫寚瀹氭枃浠跺す涓璫ss鍜宩s杩涜鍘嬬缉
  • 浣跨敤鍒颁簡JQuery鎻掍欢,鎵€浠ユ湁寰堝閮芥槸鍘嬬缉杩囩殑js銆傛墍浠ュ鏂囦欢鍚嶇О涓繚瀛榤in鐨勪笉杩涜鍘嬬缉
  • 涓嶉渶瑕佸浠芥枃浠?/li>
  • 濡傚湪绗竴娆¤闂枃浠舵椂鍊欒繘琛屽帇缂╂垨搴旂敤绋嬪簭鍚姩鏃跺€欒繘琛屽帇缂? 

瀹炵幇锛堝簲鐢ㄧ▼搴忓惎鍔ㄥ帇缂╃増鏈級锛?nbsp;

  • 寮曠敤 Yahoo.Yui.Compressor.dll
  • 鍦℅lobal.asax鐨凙pplication_Start浜嬩欢涓姞鍏ュ鐞嗕唬鐮?-code锛?/li>

ar files = System.IO.Directory.GetFiles(Server.MapPath("~/"), "*.*", SearchOption.AllDirectories);

foreach (var file in files)
{
    FileInfo finfo = new FileInfo(file);
    //todo 浣犲彲浠ュ湪鏂囦欢澶规坊鍔犲彲浠ユ枃浠惰褰曟渶鍚庡帇缂╂椂闂?鍐嶅垽鏂枃浠舵渶鍚庝慨鏀规椂闂存槸鍦ㄤ笂涓€娆″帇缂╂椂闂翠箣鍚庣殑鏂囦欢.鑰屼笖杩欓噷杩樺彲浠ュ仛寮傛澶勭悊
 
    string strContent = File.ReadAllText(file, Encoding.UTF8);
    //鍚嶇О涓嶆槸min
    //todo 鍙兘闇€瑕佹洿瀹屽杽鐨勫垽鏂?/code>
    if (!file.Contains(".min."))
    {
        //鍙栨秷鏂囦欢鍙
        File.SetAttributes(file, FileAttributes.Normal);
        if (finfo.Extension.ToLower() == ".js")
        {
            //鍒濆鍖朖S鍘嬬缉绫?/code>
            var js = new javascriptCompressor();
            js.CompressionType = CompressionType.Standard;//鍘嬬缉绫诲瀷
            js.Encoding = Encoding.UTF8;//缂栫爜
            js.IgnoreEval = false;//澶у皬鍐欒浆鎹?/code>
            js.ThreadCulture = System.Globalization.CultureInfo.CurrentCulture;
            //鍘嬬缉璇s
            strContent = js.Compress(strContent);
 
            File.WriteAllText(file, strContent, Encoding.UTF8);
        }
        else if (finfo.Extension.ToLower()==".css")
        {
            //杩涜CSS鍘嬬缉
            CssCompressor css = new CssCompressor();
            strContent = css.Compress(strContent);
            File.WriteAllText(file, strContent, Encoding.UTF8);
        }
    }
}
 
瀹屾暣浠g爜涓嬭浇锛?a href="https://files.cnblogs.com/xuchengzone/JS-CSS.Compressor.rar" target="_blank">http://files.cnblogs.com/xuchengzone/JS-CSS.Compressor.rar
 
https://www.cnblogs.com/stone_w/archive/2012/12/11/2812538.html

以上是关于Asp.Net浣跨敤Yahoo.Yui.Compressor.dll鍘嬬缉Js|Css的主要内容,如果未能解决你的问题,请参考以下文章

MySQL涔嬪垵浣跨敤

濡備綍鎻愰珮绋嬪簭鍛樼殑閿洏浣跨敤鐜囷紵

window10Cmd浣跨敤

SpringCloudConfig浣跨敤

vue axios浣跨敤

mac浣跨敤