How does Google's Web Toolkit support the principles of Green Web Engineering?

A follow-up to the post "Green Web Engineering"

This post examines how Google's Web Toolkit (GWT) supports the principles of Green Websites or Green Web Engineering, which were recently summarized by Eva in her post "Green Web Engineering" on the basis of state of the art technical and scientific publications.

GWT is a framework that facilitates the development of rich web applications. Here, it is necessary to distinguish between web applications and websites. Where websites are just intended to present information, web applications implement more or less complex use cases, which require them to keep logic states between successive page views. Unlike web applications, websites usually do not have logic states that have to be preserved. Additionally, the users of modern web applications expect a feature-rich user interface, which means that it should look and behave much more like a native tablet or desktop application than a website traditionally does.

As an answer to this, GWT makes heavy use of JavaScript and asynchronous XML HTTP requests. Unfortunately, the JavaScript implementations and the programming interfaces to the HTML document model and the browser model differ slightly between web browsers. Hence, it is necessary to consider these differences in the JavaScript code, which makes programming more complex and error-prone. GWT addresses this issue as its framework hides most of the incompatibilities from programmers.

A second aspect addresses JavaScript itself, which is a dynamically typed programming language. Dynamic typing adds some kind of complexity to programming because you know nothing about the specific type of a variable unless you are executing your program. This can be error-prone especially when you are developing huge applications in a team. In GWT you are not directly developing JavaScript code. Instead, you are writing your programs in Java, which is a statically typed programming language where you exactly know the type of a variable during development. As a further advantage, you can make use of all of the extensive features provided by modern development environments for Java (e.g. Eclipse, Netbeans, or IntelliJ IDEA), like syntax highlighting, type-aware code completion, code inspection, refactoring, unit tests, etc.

After developing your web application in Java, you have to transform it with the GWT compiler to browser compatible JavaScript code. This code is then embedded into a web page that acts as a host for your web application. Thus, it is possible to embed a GWT web application in any website. The GWT compiler hides most of the browser specific aspects as well as aspects that were described as principles of Green Web Engineering.

The following principles of Green Web Engineering are addressed by GWT:
  • Support caching
  • Use compression
  • Minimize JavaScript
  • Minimize and optimize CSS
  • Optimize graphical elements and logos

Support Caching

GWT supports caching through several techniques, which allow the configuration of far-future Expires headers in web servers. The JavaScript files that are created by the GWT compiler have unique file names that change even when the JavaScript files’ content changes only slightly. You can easily define a far-future Expires headers for these kinds of files, because a file name is never used again for different content.

A similar technique is used for application specific CSS files, which are also processed during compilation to ensure the uniqueness of the file name and to apply further techniques, which are described in more detail below. For arbitrary static content, e.g. PDF files or images, unique file names can also be generated automatically.

Use Compression

HTTP compression of JavaScript files with DEFLATE/GZIP is not properly supported by all modern web browsers. Hence, GWT embeds JavaScript code into special HTML files to support also compression for those kinds of browsers.

Minimize JavaScript

For production purposes, the GWT compiler outputs obfuscated JavaScript. The obfuscation procedures apply also minimization techniques. Obfuscation replaces the names of variables, functions/methods, function/method parameters, and classes with the shortest possible unique names. Minimization removes unnecessary white space, line breaks, and comments. This protects not only your intellectual property rights, because it is hard to interpret the resulting JavaScript code, but also reduces the download size and accelerates parsing.

Minimize and Optimize CSS

During compilation, GWT can minimize and optimize CSS files. It removes unnecessary white space, line breaks, comments, and empty CSS rules. Furthermore, it merges CSS rules with identical selectors and rules with identical properties to one rule. Rules that are never used in your web application are removed.

Optimize Graphical Elements and Logos

With GWT it is easily possible to combine several images, e.g. for buttons, to one or a few image files. The single images in these combined files are then accessed with a technique called spriting. Here, you put the image to the background and you view only a small piece of it that is as big as your original image. The necessary coding is transparently done for you by the GWT compiler. This technique reduces the number of round trips because less images have to be loaded and thus reduces the HTTP protocol overhead. By applying unique file names to the generated images, long lasting cache Expires headers can be defined.


This short feature overview shows that many techniques that are appropriate for Green Web Engineering are supported by GWT out of the box with no or only minimal additional effort. Nevertheless, it should be mentioned that Google developed these features not to support Green Web Engineering, but rather to enable the “development of high-performance web applications”1. Luckily, both goals overlap in certain areas, so that it is possible to choose only those techniques that reduce processor time and network traffic, but to leave the counterproductive ones out. To put it in a nutshell, high-performance techniques that also support a Green Web do not require additional processor time or network capacity to speed-up a website or web application. A green web page should on average require less IT resources to serve a specific amount of clients than it would have required without the application of green techniques.

At this point, we have to keep the Rebound in mind: more and more users will, even with a green website, consume more and more processing time, network bandwidth, and finally energy. Thus it is possible that the initial savings are overcompensated by the steady growth. Seen from a broader perspective, data centers will still require more and more powerful hardware to cope with the growing demand. This causes all these impacts on Sustainable Development which are known from the life cycles of ICT products, e.g. land use and civil wars due to mining of ores2, water use and water pollution from production3, exploitation of workers in low-wage economy countries4,5, or dumping and doubtful recycling of IT in developing and threshold countries6,7,8.

Therefore, it is strongly required for a green web application or a green website to choose an Internet Service Provider who considers also these non-energy-centric sustainability aspects in his daily business practice.

  1. Google: Google Web Toolkit Overview. https://developers.google.com/web-toolkit/overview?hl=de
  2. Behrendt, S., Kahlenborn, W., Feil, M., Dereje, C., Raimund, B., Ruth, D., Michael, S.: Rare Metals. Measures and concepts for the solution of the problem of conflict-aggravating raw material extraction - the example of coltan. Umweltbundesamt [German Federal Environmental Agency] (2007). http://www.umweltdaten.de/publikationen/fpdf-l/3251.pdf
  3. Morrison, K.: WATER: THE NEXT CARBON. http://www.sustainalytics.com/sites/default/files/Water_The_Next_Carbon_Sustainalytics.pdf
  4. Bormann, S., Krishnan, P., Neuner, M.: Migration in a Digital Age. Migrant Workers in the Malaysian Electronics Industry: Case Studies on Jabil Circuit and Flextronics. World Economy, Ecology and Development e.V. [german registered association], Berlin (2010). http://www2.weed-online.org/uploads/migration_in_a_digital_age.pdf
  5. Chan, J., Ho, C.: The dark side of cyberspace. Inside the sweatshops of China´s computer hardware production. World Economy, Ecology and Development e.V. [german registered association], Berlin (2008). http://www2.weed-online.org/uploads/the_dark_side_of_cyberspace_dec.2008.pdf
  6. Brigden, K., Labunska, I., Santillo, D., Johnston, P.: Chemical contamination at e-waste recycling and disposal sites in Accra and Korforidua, Ghana. Amsterdam (2008). http://www.greenpeace.org/raw/content/international/press/reports/chemical-contamination-at-e-wa.pdf
  7. Magashi, A., Schluep, M.: e-Waste Assessment Tanzania. UNIDO e-waste initiative for Tanzania, Final Report (2011). http://ewasteguide.info/files/Magashi_2011_CPCT-Empa.pdf
  8. Knoth, R.: Scraplife - e-waste in Pakistan. http://www.greenpeace.org/international/en/multimedia/photo-essays/Scraplife---e-waste-in-Pakistan/