开发者

Does Google Closure support multiple "packages" of Javascript files?

开发者 https://www.devze.com 2023-01-16 23:55 出处:网络
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.

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 i开发者_如何学Cn 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.


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消