does CSS Sprite is default ?

Skip to first unread message


Jan 30, 2012, 9:56:10 PM1/30/12
to Google Web Toolkit
there has many small pictures in a page,does GWT will merge them by

Thomas Broyer

Jan 31, 2012, 7:12:10 AM1/31/12
As I often say: there's no magic.

GWT will only do something if you somehow "tell" it to do it: it won't try to optimize images unless they are in an ImageBundle or ClientBundle.

Note however that the default behavior for ClientBundle is actually not to create a "CSS sprite" but to use data: URIs directly embedded in the JS (and/or in the CSS for a CssResource, which is also embedded as a String in the JS) for all browsers that support it (all but IE6/7, also, IE8 will fallback to loading images from the server –without any optimization at all, IIRC– when using HTTPS, because data: URIs in an HTTPS-served page would result in a "mixed content" warning)

Sebastian Gurin

Jan 31, 2012, 1:49:06 PM1/31/12
If you use gwt client bundle for referencing your images in your gwt app, gwt compiler will decide how is best way of "storing" the images.

By default, it stores small images in with the content embedded in the urls, like: <img src="data:101010010100110". For bigger images, it store them as regular files and regular urls, like src="afile1.png"

In client bundles you can force the gwt compiler to a technic. For example, if I don't want the compiler to "inline" the data image in urls I annotate the ImageResource with @ImageOptions(preventInlining=true) as the following code shows.


public interface TestImageResources extends ClientBundle {
TestImageResources INSTANCE = GWT.create(TestImageResources.class);

ImageResource smallLion();



> --
> You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
> To post to this group, send email to
> To unsubscribe from this group, send email to
> For more options, visit this group at

Sebastian Gurin <>

Reply all
Reply to author
0 new messages