111,095
社区成员




public void JsCompressor(string a.js,string a.min.js)
{
//压缩文件a,js
//在指定目录生成a.min.js
}
public static string CompactJavascript(string jsSourceCode)
{
var url = "http://tool.css-js.com/!java/?type=js&munge=true&preserveAllSemiColons=false&disableOptimizations=false";
var web = (HttpWebRequest)WebRequest.Create(url);
web.Method = "POST";
web.Host = "tool.css-js.com";
web.Accept = "text/plain";
web.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36";
web.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
web.Headers.Add("Accept-Language", "zh-CN,zh");
var content = string.Format("code={0}", HttpUtility.UrlEncode(jsSourceCode));
var data = Encoding.UTF8.GetBytes(content);
using (var rq = web.GetRequestStream())
rq.Write(data, 0, data.Length);
using (var rs = web.GetResponse())
using (var rd = rs.GetResponseStream())
using (var rm = new StreamReader(rd))
{
var s = rm.ReadToEnd();
return s;
}
}