views:

36

answers:

2

Say I had 1 MB of compressed Javascript, all combined into one file using Google Closure.

Now 500 KB of it is only needed for one section of the site.

So I want to combine & compress the Javascript, but separate it into two packages:

  • Package A - 500 KB - used across the site
  • Package B - 500 KB - used only in one section of the site

At the moment I'm just putting a comment at the top of the Javascript files like this:

/// <package name="Main" />

And using my own custom .NET application to parse them and put them in the appropriate package.

Is it possible to do all of this with Google Closure? I'd rather use an existing solution than re-invent the wheel.

A: 

After further investigation, it looks like Closure doesn't have such a feature.

I'm going to build the feature into my own custom JS combiner, which I might open source when I have the time.

jonathanconway
+1  A: 

wrong closure compiler does have option to compress files into multiple files

for example:

java -jar compiler.jar \

--module mod1 --js src1.js --js src2.js \

--module mod2:mod1 --js src3.js

tarmo
I stand massively corrected.
jonathanconway