SpaceBear
SpaceBear

Reputation: 854

Packaging JavaScript & CSS

I was tasked with figuring out how to package JavaScript and CSS into one file per each. We have a java servlet application and we use JQuery if that makes any difference. We use ant to script our builds, so easy integration with Ant would be nice. We want to do this to reduce caching issues and to reduce number of requests to the servlet.

I found few tools out there, but not sure what are pros/cons of each. Here is the list so far:

Do you guys have any recommendations, warnings, advices? Or maybe a better tool/framework?

Thanks in advance!

Upvotes: 4

Views: 1666

Answers (4)

cweiske
cweiske

Reputation: 31107

Replace "being nice" with "a must". You absolutely want something that integrates with your build tool since you do not want to minimize your files manually again and again and again and again and again and again and again and again and again and again.

Upvotes: 2

icvg
icvg

Reputation: 197

Jawr - very nice library, makes everything for you, simple to integrate (at least with its Grails PLugin). The small problem, I havn't found a way (may be it exists) to integrate ALL bundle's dependencies in a single file. (if you don't have dependencies between bundles (modules), you won't regret this decision).

Upvotes: 1

Annie
Annie

Reputation: 6631

For JavaScript, the closure compiler integrates with Ant. It can concatenate and minify your JS. You can also use YUI compressor. Here's an example of using YUI compressor with Ant for JS and CSS.

Upvotes: 4

Andrew
Andrew

Reputation: 13853

By far my favorite template is HTML5 Biolerplate The build script there is pretty good as a template.

Also, versioned files with long cache times will greatly improve load times.

Upvotes: 2

Related Questions