user1768830
user1768830

Reputation:

How GWT stacks up to Golden Rules of Performant Web Apps?

The so-called "14 Golden Rules of High-Performance Websites" are:

Rule 1 - Make Fewer HTTP Requests
Rule 2 - Use a Content Delivery Network
Rule 3 - Add an Expires Header
Rule 4 - Gzip Components
Rule 5 - Put Stylesheets at the Top
Rule 6 - Put Scripts at the Bottom
Rule 7 - Avoid CSS Expressions
Rule 8 - Make JavaScript and CSS External
Rule 9 - Reduce DNS Lookups
Rule 10 - Minify JavaScript
Rule 11 - Avoid Redirects
Rule 12 - Remove Duplicate Scripts
Rule 13 - Configure ETags
Rule 14 - Make AJAX Cacheable

I'm wondering which ones GWT addresses auto-magically for its developers. For instance, as a single-page app, I'm sure Rule #1 (fewer HTTP requests) is covered under the hood. But what about Rule 9 (reduced DNS)? Rule 13?

Of these, the only one I don't think is applicable to any web framework is #2 (CDN), so let's pretend that's not on the list. So I ask: of the remaining rules, which ones does GWT address, and which ones does it not?

Upvotes: 2

Views: 193

Answers (1)

Thomas Broyer
Thomas Broyer

Reputation: 64541

  1. ClientBundle will inline resources (CSS, images as data: URLs); historically, ImageResources are composed into "CSS sprites" for IE6/7 (support for IE6/7 will be removed in the next version of GWT, but spriting is still possible behind a switch). RequestFactory does batching (this can be achieved with GWT-RPC too, using a command pattern and custom wrappers)
  2. using the xsiframe (or xs) linker, your scripts don't need to be hosted at the same origin as the HTML host page (xs stands for cross site) so that they can be served by a CDN
  3. GWT generates files with unique names to make far future expires possible; see http://www.gwtproject.org/doc/latest/DevGuideCompilingAndDebugging.html#perfect_caching
  4. You can GZip the output of the GWT compiler yourself (or let your HTTP server do it on-the-fly; AppEngine will do it automatically for your for instance), or add <inherits name="com.google.gwt.precompress.Precompress"/> to your gwt.xml file to have the GWT compiler automatically produce gzip'd files (they're generated alongside the original uncompressed files, but you can turn off generation of uncompressed files by adding <set-configuration-property name="precompress.leave.originals" value="false" /> to your gwt.xml file; compressed files will have a .gz extension; and by default only .html, .css and .js files will be compressed)
    GWT-RPC responses are also automatically gzip'd when that makes sense (size exceeds a (non-configurable) threshold).
  5. GWT won't really help here as you are in charge of the HTML host page. Most applications use CssResources for CSS though, and that rule doesn't apply there either (the rule is about download order/priority)
  6. Same as #5
  7. GWT uses one single instance of CSS expression: to maintain the ZIndex of the glass panel relative to the ZIndex of a PopupPanel, but it's only for IE6/IE7 so it'll be removed in the next version of GWT; and I don't think it had a real impact on performances anyway.
  8. GWT generates JS and CSS (generally inlined in the JS though) so yes they're external indeed.
  9. GWT doesn't make it easy to use several unique host names.
  10. GWT indeed minifies JS (and CSS, and optimizes images too), it also optimizes them using several algorithms (dead-code pruning, function inlining, minified JS organized so that it gzips better, function merging)
  11. GWT doesn't use redirects (it doesn't do much things server-side to being with); this rule is not about tooling, it's about your code.
  12. Another rule that's on your side rather than on tooling.
  13. Same as above (see also #3 and #14)
  14. Same as above; though GWT-RPC and RequestFactory are "RPC" protocols that won't be able to take advantage of HTTP caching. This rule applies to "REST" requests (which are possible with GWT of course, through RequestBuilder, XMLHttpRequest or JsonpRequestBuilder, but GWT only provides the client side of it, you're responsible for the server-side hence cacheability)

Upvotes: 8

Related Questions