Javascript Compressor

When you download JQuery plugins there are often two versions. A ‘normal’ version and a compressed (*.min.js) version. The purpose of this compressed file is to speed up your application, especially for slow speed internet connection. A very good website/tool to compress your Javascript files is I tried a couple of files and it will reduce the JavaScript file size with 50%.

When you need to debug your application it is not very usefull to use the compressed one but in production it really is. To switch very easy from the compressed version to the ‘normal’ version and the other way around you can create a static variable where you define the location of the JavaScript file. Use the static variable to add the file to your page/header. Now you can switch versions (normal/compressed) by changing the static variable (in only one file).

public static final String JQUERY_BASE = "base/jquery-1.2.6.min.js";

(Wicket) Page:

add(HeaderContributor.forJavaScript(JQuery.class, JQuery.JQUERY_BASE));

Leave a Reply




You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>