7. 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?
8. 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”
10. 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
11. 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)
15. 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
16. 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
17. 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
20. 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.
29. 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.
30. 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 ://
31. Bundling of Resources into Modules
with Dependency Management
• require tag for the module
Hinweis der Redaktion
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<g:resource/><r:script/><r:script/> tag, the inline script will be moved to the location of the second <r:layoutResources/> 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.