1
Stack Overflowの別の質問で、JavaScriptファイルをかなり小さくすることができるGoogle Closure Compilerにコードを送信するための非常に役立つコードスニペットがありました。Google Closure Compilerはコンパイルされたコードを返しません。
しかし、私が直面している問題は、コンパイルされたコードを返さないというケースです。
コード:
これが機能する、すなわちコード縮小さを返す:
Dim script = "function test(name) {alert(name);}test('New user');"
この1つは、他の一方で、何も返しません。統計情報は送信され...、ないコンパイルされたデータされています全くcasue何ができるか
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
:実際に作業を行うコードの
Dim script = "function test(name) {alert(name);}"
休憩?私は知りたいと思っています。
私は高度な最適化で、同じことをテストし、アラートを削除し、期待どおりに機能を取り除きます。 – kmfk
あなたは完全に正しい - 私はそれを見ていないのに疲れていたに違いない...そして最初のコメントには申し訳なく思っていた、私は間違っていた。 – pimvdb
ああ、汗がない。ただもっとコーヒーが必要です:] – kmfk