我剛剛創建了Javascript &使用YUI Compressor優化文件大小的CSS處理程序& GZip或Deflate壓縮程序取決於請求標頭。以下代碼用於通過GZipStream類壓縮文件。但我發現它只能從減少JQuery 1.3.2(YUI壓縮)文件大小58KB - > 54KB。用GZip,Deflate壓縮javascript文件的最佳組件是什麼?
public void GZipCompressFile(string filePath, string compressedFilePath)
{
FileStream sourceFile = File.OpenRead(filePath);
FileStream destFile = File.Create(compressedFilePath);
using (GZipStream compStream = new GZipStream(destFile, CompressionMode.Compress))
{
int theByte = sourceFile.ReadByte();
while (theByte != -1)
{
theByte = sourceFile.ReadByte();
}
}
sourceFile.Dispose();
destFile.Dispose();
}
另一方面,我使用gz格式(超壓縮模式)壓縮文件與7-Zip。壓縮文件的大小隻有19.3 KB。但是,我不能使用7-Zip作爲默認壓縮器。因爲它不能使用Deflate壓縮器方法壓縮文件。
你有沒有壓縮文件的任何組件GZip & Deflate文件類型?或者你有任何想法編輯我的GZipCompressFile方法?此外,所有新的瀏覽器(IE8,FF3.5,Opera 9.6,Safari 4)是否都支持壓縮方法(包括GZip和Deflate)?
我認爲它發生偏轉,其DEFLATE – rahul 2009-07-01 07:02:11
對不起。這是我的錯誤。 – 2009-07-01 07:16:08