views:

38

answers:

1

Hi,

I have to make a web application using GWT. The project has a core module that'll expose a set of apis to be used by other apps; each of these app are unrelated. Each shall be loaded in a separate iframe.

My idea was to compile core into core.js and each app shall have its own app1.js app2.js and so on...

App1

script type="text/javascript" src="core.js" ></script>
script type="text/javascript" src="app1.js" ></script>

with this design, due to browser caching, each app laod only the app.js which should be smaller ~20kb in size.

Making a core module is straightforward but the apps are problematic. The reason being after compilation, each app contains the entire GWT library - this substantially increases the download size of the complete webapp.

Can anyone suggest a way to get aroung this problem ? I've checked similar questions on SO, but failed to find a simple working answer fr the problem.

Thanks for any help.

+2  A: 

It can't be done.

GWT is meant to be a monolithic compile. It will take all your java code, assume that no other code exists other than what was provided to it, and then generate optimized javascript code. While doing so, it will only compile portions of standard GWT library that are actually being used by your program.

Because of the way GWT works, its always going to be inefficient to include multiple GWT modules on the same page.

Instead, here is what I'd recommend -

  1. Have one GWT module per application, not one per page. And putting two modules on the same page is definitely not right
  2. Share java code between modules, not javascript. This means your shared library will never be compiled as javascript
sri
Hmm.. That pretty much rules out the use of gwt for the project then. Even if I share java code,the core gwt lib shall still be included/compiled with each app - which obvisouly is a waste. Thanks for the ans though
Code freak