Thursday, May 4, 2017

Re: Loading only relevant shared code in an html page.

You have 2 possibilities (that I haven't explored personally, so I couldn't comment on the pros on cons)
  • use a single entry-point (single module), and use code splitting (GWT.runAsync) to only load what's needed (and probably a bit more that'd happen to be shared with other pieces of code; in so-called "leftover" chunks); shared code between "pages" will then really be shared (at the HTTP/caching level)
  • use one entry-point (one module) per "page"; code shared between several modules will be included (duplicated) in each generate script though, with absolutely no sharing. And yes you can have as many as you like. I'm not aware of any limitation in the GWT Eclipse Plugin, and even if there was, I'd highly recommend using a build tool (Gradle, Maven, Ant, or even Make if you like) that will *not* have any limitation (or at least whose limitations could be worked-around). Actually, the thing you'll have to balance will be between running the GWT compiler once with all the modules in argument vs. once per module, I'd say a priori a balance between memory and time.
Unfortunately, GWT 2.x cannot have the best of both worlds (one "entry point script" per page, with code-sharing between modules) like, say, Webpack can do.
(see PRPL https://developers.google.com/web/fundamentals/performance/prpl-pattern/ , Webpack entry-points https://webpack.js.org/concepts/entry-points/#multi-page-application and CommonsChunkPlugin https://webpack.js.org/plugins/commons-chunk-plugin/ )

On Thursday, May 4, 2017 at 1:23:31 PM UTC+2, NxS wrote:
Hello,

I'm a GWT newbie.

1. Is it possible to load only a subset of a module's shared code in an html page, declaratively or otherwise? 

Use-case: I may have a lot of shared code in my overall application, not all of which may be relevant to every single html page (of my overall application). So, I'd like to be able to load only select portions of the shared code in a given html page, ignoring portions of it not used by the page.

2. If the above is not possible, then... Is it possible to have multiple modules in a single Eclipse project, using either the Eclipse IDE or the webAppCreator command-line tool? 

The idea is this: 

IF I have a total of 10000 methods in my overall application's shared code, 
    AND 
IF I have 100 pages each requiring 100 methods only (on average),
THEN, I wouldn't want to create 100 different Eclipse projects for these 100 modules (consisting of 100 functions each) when a single Eclipse project could well do the job.

Thanks and regards,
NxS

PS: When I say "load" above, I mean loading of the code by the browser, generating a proportional amount of network traffic.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment