Resources plugin
Upcoming SlideShare
Loading in...5
×
 

Resources plugin

on

  • 286 views

Resource Plugin is a Grails plugin for managing static resources.

Resource Plugin is a Grails plugin for managing static resources.

Statistics

Views

Total Views
286
Views on SlideShare
286
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Web applications typically rely heavily on what we call static resources, such as Javascript, CSS and image files. In a Grails application, they are put into a project's web-app directory and then referenced from the HTML.
  • Web applications typically rely heavily on what we call static resources, such as Javascript, CSS and image files. In a Grails application, they are put into a project's web-app directory and then referenced from the HTML.
  • Applications grow , more technologie s
  • Declaring static resources in a modular and reusable mannerPlugin old way new way
  • Disposition url relative to grails web-appCss default to headJs default to end of body deferStill you can change the disposition
  • The Resources plugin achieves these goals by introducing new artefacts and processing the resources using the server's local file system.In tandem with Sitemesh layouts and the Grails plugin dependency system, you gain the ability to express dependencies on specific UI libraries, and the ability to specify the resources that a page needs anywhere in the page GSPs or even in rendered GSP templates.
  • r:script : default is “defer” , everywhere inlineUsed r.script from custom tags: r.script(attrs, Closure)
  • The Resources plugin achieves these goals by introducing new artefacts and processing the resources using the server's local file system.In tandem with Sitemesh layouts and the Grails plugin dependency system, you gain the ability to express dependencies on specific UI libraries, and the ability to specify the resources that a page needs anywhere in the page GSPs or even in rendered GSP templates.
  • The Resources plugin calls inline images and scripts "ad-hoc resources".Not defined in modules tag, the inline script will be moved to the location of the second gin also updates the links in the CSS files automatically
  • This plugin provides the Resources framework for Grails.The issues that the Resources framework tackles are: Web application performance tuning is difficultCorrect load order for resources that depend on othersDeferring inclusion of JavaScript to the end of the documentThe need for a standard way to for Grails plugins to expose static resourcesThe need for an extensible processing chain to optimize resourcesPreventing inclusion of the same resource multiple timesThe need for identical behaviour in development and production
  • had to include the disposition “image” which is not a predefined disposition – it is just anything other than “head” or “defer” to prevent the image being rendered by the r:layoutResources tags.
  • ~/.grails/2.2.4/projects/boostrapKickStartFast/tomcat/work/Tomcat/localhost/boostrapKickStartFast/grails-resources

Resources plugin Resources plugin Presentation Transcript

  • Grails Resources Plugin Alidad Soleimani (Grails developer) Net Jets Inc. alidadasb https://github.com/alidadasb
  • Static Resource • CSS • JS • Images /web-app/ <link rel="..." href=...> <g:external dir="css" file="main.css" />
  • Static Resource
  • Challenges • • • • • • Complex Applications Plugins resources Dependency between resources Multiple copies of a resource Different version of a resource Order of resources
  • Managing Dependencies • Mark Palmer’s blog
  • Optimization & Performance • • • • Cache resources Minifying resources Zipping Bundling Resources
  • Performance Golden Rule • “80-90% of the end-user response time is spent on the frontend. Start there”, Steve Souders • How can we improve web performance going forward?
  • 14 Rules for Faster-Loading Web Sites Steve Souders • • • • • • • • • • • • • • • Rule 1 - Make Fewer HTTP Requests Rule 2 - Use a Content Delivery Network Rule 3 - Add an Expires Header Rule 4 - Gzip Components Rule 5 - Put Stylesheets at the Top Rule 6 - Put Scripts at the Bottom Rule 7 - Avoid CSS Expressions Rule 8 - Make JavaScript and CSS External Rule 9 - Reduce DNS Lookups Rule 10 - Minify JavaScript Rule 11 - Avoid Redirects Rule 12 - Remove Duplicate Scripts Rule 13 - Configure ETags Rule 14 - Make AJAX Cacheable “will cut 25% to 50% off response time when users request a page”
  • Grails’ static resource management • 2008 - UI Performance Plugin • 2009 - Resources Plugin • Asset-pipeline
  • Introduction to resources plugin        http://grails.org/plugin/resources Authors: Mark Palmer, Luke Daley 2009 initial version 2011 Plugin in 1.3.x 2012 shipped with Grails 2.0 Current stable version 1.2.RC2 Organization : Grails Community
  • Resources Plugin A plugin that provides a powerful streamlined asset pipeline “This plugin represents a new way of declaring and linking to static resources in your application and plugins. Resource dependencies can be declared and pages simply indicate which resource modules they require. The plugin does the rest, and provides a processing pipeline for advanced optimizations.”(Colin Harrington)
  • Defining Modules • Define inside config.groovy • Define inside *Resources.groovy
  • Declaring modules MyResources.groovy
  • Referring to Resources Page1.gsp
  • Defining Modules • Resources from a given module are loaded in the order they are defined in the module • Resources from modules are loaded in module dependency order
  • Tag Libs • r:external : This tag renders the right kind of links to external resources, based on their type • r:img • r:layoutResources • r:require • r:resource: This tag returns the URL to use link to a resource. g:resource will delegate to r:resource automatically
  • Defining Layout Main.gsp The r:require tag tells the framework which resource modules the current GSP requires. The <r:layoutResources/> is a placeholder for where to include the resources
  • Referring to Resources Page1.gsp
  • Ad-hoc resources • As of Grails 2.0 <img> is aware of resources
  • 5 primary functions • Bundling of resources into modules with dependency management. • Processing of resources prior to serving them. • Tag library to render links to resources in modules. • Tag library to render links to other resources which are not in modules. • Service of resources to clients based on appropriate requests.
  • Processing of resources • Extensible pipeline of mappers Peter Ledbrook
  • Phases:
  • Images:
  • Debugging println grailsResourceProcessor.dumpResources()
  • Other Plugins • • • • Cached Resources Zipped Resources Less CSS Resources Modernizr for Grails
  • Configuration
  • YSLOW
  • YSLOW
  • Asset-PipeLines • On the fly processing - No more waiting for your assets to reload after making a change • Compiled assets by generator - No more hanging up application boot times while processing files. `grails assetprecompile` • Reduced Dependence - The plugin has compression, minification, and cache-digests built in. • Easy Debugging - Makes for easy debugging by keeping files seperate in development mode. • Simpler manifests and taglibs - Read on for more information.
  • Bundling of Resources into Modules with Dependency Management • define resource modules that have a name and contain one or more resources • declared in separate files named like ModuleResources.groovy • separate modules block within Config.groovy • The resources can either be local to the application, and declared with the usual map of attributes, such as dir: and file:, or external to the application, with an absolute url containing ://
  • Bundling of Resources into Modules with Dependency Management • require tag for the module