JavaScript compression

From MapbenderWiki

Jump to: navigation, search

Contents

reasons for packing JS

Compressing JS code should be desirable

  • loading speed increases
  • traffic is minimized

Best practice

The best practice so far to achieve minimal JS files is to minify via JSMin, and let your web server gzip the output.

JSMin

  • A JavaScript Minifier by Douglas Crockford (JSMin details about JSMin).
  • Here is a JSMin test site
  • At the moment, JavaScript compression is done via JSMin. There are other obfuscators out there, but although they might produce less data, they need time on the client side to decompress (see http://www.julienlecomte.net/blog/index.php?s=minified&sbutt=Go)
  • Compression is done by copying each script into the test site. There are other solutions, like a Perl script (we also extract JSDoc via perl, so maybe we could have a build process in Perl?). We should definitely have a script for the build process in the near future! Who volunteers?
  • The compressed scripts are deployed with the release (replacing the uncompressed scripts), but are not checked in the SVN.

gzip

Follow the instructions at [Installation].

Personal tools