Provides a utility object for rendering a Page's HEAD elements and control HEAD elements.
PageImports automatically makes the HEAD elements available to Velocity templates and JSP pages through the following variables:
- $headElements - this variable includes all HEAD elements except JavaScript elements
- $jsElements - this variable includes only JavaScript elements
By splitting JavaScript elements from other HEAD elements allows you to place JavaScript elements at the bottom of the Page which allows the HTML content to be rendered faster.
To use the HEAD elements simply reference them in your page template. For example:
<html> <head> $headElements </head> <body> $form $jsElements <body> </html>
Its not always possible to move the JavaScript elements to the bottom of the Page, for example there might be JavaScript scoping issues. In those situations you can simply place the JavaScript elements variable in the Page HEAD section:
<html> <head> $headElements $jsElements </head> <body> $form <body> </html>
Please note: the variables
$headElements and
$jsElements are new in Click 2.1.0. For backwards compatibility the HEAD elements are also available through the following variables:
- $imports - this variable includes all HEAD elements including JavaScript and Css elements
- $cssImports - this variable includes only Css elements
- $jsImports - this variable includes only Javascript elements
Please also see {@link org.apache.click.Page#getHeadElements()}, {@link org.apache.click.Control#getHeadElements()}.