1
在Stack Overflow的另一个问题中,我遇到了一个非常有用的代码片段,可以将代码发送到Google Closure编译器,该代码片段可以很好地缩小JavaScript文件。Google Closure编译器不会返回任何编译代码?
然而,我面临的问题是,它不会返回任何编译的代码,我不希望它这样做。
代码:
这工作,即返回精缩代码:
Dim script = "function test(name) {alert(name);}test('New user');"
这一个,而另一方面,不返回任何东西。统计数据被发送,但没有编制的数据...:
Dim script = "function test(name) {alert(name);}"
休息,实际上做的工作代码:
Dim Data = String.Format(ClosureWebServicePOSTData, HttpUtility.UrlEncode(script))
_Result = New StringBuilder
_HttpWebRequest = DirectCast(WebRequest.Create(ClosureWebServiceURL), HttpWebRequest)
_HttpWebRequest.Method = "POST"
_HttpWebRequest.ContentType = "application/x-www-form-urlencoded"
'//Set the content length to the length of the data. This might need to change if you're using characters that take more than 256 bytes
_HttpWebRequest.ContentLength = Data.Length
'//Write the request stream
Using SW As New StreamWriter(_HttpWebRequest.GetRequestStream())
SW.Write(Data)
End Using
Dim response As WebResponse = _HttpWebRequest.GetResponse()
Using responseStream As Stream = response.GetResponseStream
Dim encoding As Encoding = System.Text.Encoding.GetEncoding("utf-8")
Using readStream As New StreamReader(responseStream, encoding)
Dim read(256) As Char
Dim count As Integer = readStream.Read(read, 0, 256)
While count > 0
Dim str As New String(read, 0, count)
_Result.Append(str)
count = readStream.Read(read, 0, 256)
End While
End Using
End Using
可能是什么casue呢?我很想知道。
我测试一样,用先进的优化和消除警报,并预期它去除功能。 – kmfk 2011-02-09 18:57:39