Code Compression - Ajax Patterns

Code Compression

From Ajax Patterns

(Stub pattern - should be expanded)


Contents

Ajax/Javascript Programming and Usability in "Ajax Design Patterns" Book

Problem

JavaScript code takes up some size, therefor bandwidth which needs resources on the server, and loading time at the client.

Solutions

Minify the JavaScript code on the server once, and cache it transparently.

pack:tag

  • pack:tag - A static-resource compressing JSP-Taglib. It caches ad hoc compressed JavaScript or CSS in memory (in a Java Servlet) or in a generated file. It works transparently to the developer and the compressing-algorithms are pluggable.
    Features
    • Minification of JavaScript and Cascading Style Sheets
    • Combination of resources
    • Caching to filesystem or memory (servlet)
    • When caching to memory, the minified content is additional gzipped
    • Automatically updates on file changes
    • Apache Standard Taglib support for evaluations
    • Compression and hashcode-generation adjustable on single resources

Go to the pack:tag project site, or to the developer reference.

Jawr

  • Jawr - helps develop java web apps with heavy use of javascript. It does so by allowing you to split the .js codebase in as many files and directories as desired, without compromising page loading times. In fact, it will improve loading times since it will join the files into one or several bundles (which is easily configurable), and afterwards the bundles will be minified and gzipped. This way you can have a nicely modularized codebase that is easy to mantain instead of a couple of huge javascript files. Jawr has a development mode in which instead of the bundles, you get each member separately and with no minification, so you can use an exploded war directory and test changes on the fly. All without having to change the JSPs you are testing. Finally, you get the same advantages (modularization and compression) for CSS files.

dojo

Want To Learn More?

http://rakaz.nl/item/make_your_pages_load_faster_by_combining_and_compressing_javascript_and_css_files http://ajaxian.com/archives/protopacked-213-protoype-scriptaculous-32kb