Conditionnal css import : button...

Hello,

I noticed that button.css seems to be loaded by the browser only when a button exists in the application.
I think it is the the same for tables, tree…

I haven’t found documentation on how it is done. I browsed vaadin jar sources but i didn’t find anything on it.

Could anybody explain how this import is done ?

if you’re talking about the button.css in vaadin, it is actually never loaded. When Vaadin is built into a jar file, all the small css files like button.css, textfield.css, table.css etc. are combined into one big styles.css.

So when the application is started, the whole theme is downloaded through styles.css at once. Vaadin in itself doesn’t do any conditional loading.

The combination is done because vaadin has quite a lot of css and loading one big file is faster than loading a bunch of small files.

Thanks for your answer.

What about this mecanism when we are in a portal (Liferay for me) ?

My portlets integrate the vaadin jar.

My portal uses a widgetset and a theme in Liferay ROOT/html/ directory.

Does my specific theme have a “css sprite” mecanism at loadtime or have i to do something for it (compiling a jar for my theme…) ?

The use of sprites is completely optional and is handled for some Vaadin standard themes at build time by a separate utility, as they include a very large number of small images. It is not necessary to use sprites in application specific parts of themes of applications, and you would have to select and use some spriting solution yourself if you want to use it for your application theme as well - no such utility is included in Vaadin JAR.

On Liferay, you can copy your application specific theme to the same directory as the standard themes and then use setTheme(“mytheme”) in your application.
It is also possible to use the Liferay mechanisms for application specific CSS (declaring the CSS files to use in liferay-portlet.xml etc. if I remember correctly), bypassing Vaadin themes for such additional CSS.

EDIT: As the original question was about combining CSS files rather than images, the answer for that is the same as for sprites: it is done during Vaadin core build for the standard themes but no tools for that are included in the JAR. You would need to select appropriate tools for it and use them in your build if you need to do so, but most application themes are not complex enough to really warrant this.