3. Intro
● Resources plugin
– http://grails.org/plugin/resources
● Installed by default in Grails 2.0
– Available in 1.3.x branches
● Written by Marc Palmer & Luke Daley
14. UI Performance plugin
● http://grails.org/plugin/ui-performance/
● minification of CSS and JS
● compression
● css sprites
● bundling of CSS and JS
● build time
15. Resources Plugin
● Pluggable framework for handling static resources
● runtime ":resources:1.2-RC1"
● “This plugin represents a new way of declaring and
linking to static resources in your application and
plugins. Resource dependencies can be declared
(e.g. jQuery UI requires jQuery) and pages simply
indicate which resource modules they require. The
plugin does the rest, and provides a processing
pipeline for advanced optimisations.”
16. Using Resources in your Layout
<html>
<head>
<g:layoutTitle/>
<r:layoutResources/>
</head>
<body>
<g:layoutBody/>
<r:layoutResources/>
</body>
</html>
31. disposition
● link disposition (head vs defer)
● Successive calls to <r:layoutResources>
– Once in the <head/>
– Once before the closing </body> tag
● Blocking the UI!! Don't do it!
● <r:layoutResources disposition='defer'/>
35. Mapper Phase
● GENERATION
– create new assets = compile less files
● MUTATION
– alter/improve assets (may mean creating new/deleting aggregated
resources) = spriting
● COMPRESSION
– reducing the file size but maintaining semantics = minify
● LINKNORMALISATION
– convert all inter asset references into a normal form = css links
● AGGREGATION
– combining multiple assets into one = bundling
36. Mapper Phase
● RENAMING
– moving of physical assets = hashing
● LINKREALISATION
– convert normalised inter asset references into real form = css links
● ALTERNATEREPRESENTATION
– attach different representations of the asset = gzipping
● DISTRIBUTION
– moving assets to their hosting environment = s3, cdn
● ABSOLUTISATION
– update inter asset references to their distributed equivalent
● NOTIFICATION
– let the world know about the new resources = cache invalidation
37. cached-resources
● runtime ":cached-resources:1.0"
● http://grails.org/plugin/cached-resources
● Files/resources use a SHA-256 hash
● Delegates to the cache-headers plugin
– ETag header
– Last-Modified header