Skip to content
Martin Goellnitz edited this page Dec 8, 2015 · 4 revisions

Dealing with Stylesheet and JavaScript Codes

Tangram is prepared to deal with Cascading Style Sheets (CSS) and JavaScript codes at several stages of the development process of a web application.

Static Codes

Static codes mean code files in your source code repository. These can be references from your templates depending on their respective location with relative URLs placed verbatim in your template code.

Tangram Gradle Plugin

If you use the Tangram Gradle Plugin all JavaScript and CSS resources in your project will be automatically minified on archieve file generation. You will not need too store files in the rather unreadable state in your version control system.

Dynamic Codes

The prefered way to use CSS and JavaScript should perhaps be to place the in the repository. Tangram comes with the notion of so called "code resources" which means source code with a certain mime type and a given annotation.

If you create e.g. a code instance with the mime type text/css and the annotation screen you are prepared to use it as a stylesheet.

Inclusion

The core system contains templates to use code resources of mime types text/css and application/javascript.

Again these resource are minified like in the static case with the Tangram Gradle Plugin, but now through an on the fly minification.

The template also include a distinction between small and larger codes, so that small code get included inline while larger codes are referenced by URL.

Client Side Caching

Even dynamic CSS and JavaScript codes don't change that often and you want to avoid minification to take place unneccessarily often. So CSS and JavaScript resource should have a rather long time to live in caches along the way to the customer's browser.

Since Tangram comes with the templates rendering the code resources, it also needs to deal with the necessary HTTP headers to allow for caching allong the delivery chain.

The default cache times for CSS and JavaScript are seven days and can be configured in you application in the view settings map.

viewSettings.properties defaults from the tangram core system:

cssCacheTime=10080
jsCacheTime=10080
imageCacheTime=10080
Clone this wiki locally