Minify JavaScript with C# and .Maui APIs

using System;
					
public class Program
{
	public static void Main()
	{		
	    var request = (System.Net.HttpWebRequest)
                System.Net.WebRequest.Create("https://api.dotmaui.com/client/1.0/jsmin/");

	    var postData = "apikey=YOUR_API_KEY";
	    postData += "&url=https://code.jquery.com/jquery-3.4.1.js";
	    postData += "&asciionly=false";
        
	    var data = System.Text.Encoding.ASCII.GetBytes(postData);

	    request.Method = "POST";
	    request.ContentType = "application/x-www-form-urlencoded";
	    request.ContentLength = data.Length;

	    using (var stream = request.GetRequestStream())
	    {
                stream.Write(data, 0, data.Length);
	    }

	    var response = (System.Net.HttpWebResponse)request.GetResponse();

	    var responseString = new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd();	
	
	    Console.WriteLine(responseString);
		
	}
}

Leave a Comment

Your email address will not be published. Required fields are marked *