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>
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的主要内容,如果未能解决你的问题,请参考以下文章