JavaScript trim Filter ver. 1.2

This is a Java servlet filter (as per Servlet API 2.3). jstrimFilter lets you decrease the size of JavaScript file your server will send to all clients. Filter removes extra spaces and line breaks as well as remarks from JavaScript code. For modern applications the size for JavaScript libraries is huge, so you can save a lot of traffic with this filter.

How to use it:

a) download jstrimflt.jar and save it in WEB-INF/lib

b) describe this filter in web.xml


Also you may exclude some of your files from the processing. Parameter exclude contains a commas separated list of files excluded from the processing. E.g.:


By default this parameter is empty (do not exclude files).

c) describe a mapping for this filter in web.xml


in this case filter will be on for the each .js file

And now when you include any .js file:

<script language="JavaScript" src="your_file.js"></script>

jstrimFilter will compress it.

    For downloading:   jstrimflt.jar

 ©  Coldbeans     Comments?

See also JSOS - the largest collection of servlets and filters.


Also in JSOS: