<!-- actually imports '/app/js/myscript.js' -->
<g:javascript src="myscript.js" />
<g:javascript>alert('hello')</g:javascript>
javascript
Purpose
Includes JavaScript libraries and scripts as well as providing a shorthand for inline JavaScript.
Examples
Description
If you do not include a "src" attribute but instead provide a body, the result is an inline script.
If you are doing more advanced JavaScript and asset management we recommend checking out the Asset Pipeline plugin.
Attributes
-
contextPath
(optional) - the context path to use (relative to the application context path). Defaults to "" or path to the plugin for a plugin view or template. -
src
(optional) - The name of the JavaScript file to import. Will look in /appname/js directory -
plugin
(optional) - The plugin to look for the JavaScript in