Click here to Skip to main content
15,885,985 members
Articles / Programming Languages / Javascript

JavaScript Code Compressor

Rate me:
Please Sign up or sign in to vote.
2.75/5 (12 votes)
7 Jul 20056 min read 81K   856   27  
In this article, we will be creating a JavaScript code compressor using C#, which compresses the JavaScript code into a single line.
namespace com.sarmal.io
{
	using System;
	using System.Text.RegularExpressions;

	public class FileName
	{
		private String name;
		private String extension;
		private String path;

		public FileName(String path){
			/* match the filename and extension */
			Match match = Regex.Match(path,"(.*)(\\.[^.]+)$",RegexOptions.Compiled|RegexOptions.ECMAScript);
			name = match.Groups[1].ToString();
			extension = match.Groups[2].ToString();
			this.path = path;
		}

		public String Name {
			get {
				return name;
			}
		}

		public String Extension {
			get {
				return extension;
			}
		}

		public String Path {
			get {
				return path;
			}
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Turkey Turkey
Volkan is a java enterprise architect who left his full-time senior developer position to venture his ideas and dreams. He codes C# as a hobby, trying to combine the .Net concept with his Java and J2EE know-how. He also works as a freelance web application developer/designer.

Volkan is especially interested in database oriented content management systems, web design and development, web standards, usability and accessibility.

He was born on May '79. He has graduated from one of the most reputable universities of his country (i.e. Bogazici University) in 2003 as a Communication Engineer. He also has earned his Master of Business Administration degree from a second university in 2006.

Comments and Discussions