### Create new RichFaces Documentation Jira issue

Summary
255 characters left
Description
Environment
This will launch the RichFaces Jira page - to complete your feedback please login if needed, and submit the Jira.

JBoss.org Community Documentation

- Prev
- Next

## 6.11. < a4j:loadScript >

### 6.11.1. Description

Inserts script links to the head element. Render the value of the component, after passing it to the `getResourceURL()` method of the ViewHandler for this application, and passing the result through the `encodeResourceURL()` method of the ExternalContext.

Table 6.21. a4j : loadScript attributes

Attribute Name | Description
--- | ---
binding | The attribute takes a value-binding expression for a component property of a backing bean
id | Every component may have a unique id that is automatically created if omitted
rendered | If "false", this component is not rendered
src | name of JavaScript resource to load.

Table 6.22. Component identification parameters

Name | Value
--- | ---
component-type | org.ajax4jsf.LoadScript
component-family | org.ajax4jsf.LoadScript
component-class | org.ajax4jsf.component.html.HtmlLoadScript
renderer-type | org.ajax4jsf.LoadScriptRenderer

### 6.11.2. Creating on a page

To create the simplest variant on a page use the following syntax:

Example:

    <a4j:loadScript src="scripts/someScript.js"/>

### 6.11.3. Creating the Component Dynamically Using Java

Example:

    import org.ajax4jsf.component.html.HtmlLoadScript;

    ...

    HtmlLoadScript myScript = new HtmlLoadScript();

    ...

### 6.11.4. Key attributes and ways of usage

As it was mentioned above this component returns its value as the value of the "src" attribute passing it to the `getResourceURL()` method of the ViewHandler for this application, and passing the result through the `encodeResourceURL()` method of the ExternalContext.

It means that the Context is inserts automatically to the link. And calls like `resource://` is properly handled.

Except this - you may be free to put your script links right from the child page while using facelets templates.

### 6.11.5. Relevant resources links

On the component LiveDemo page you can see the example of <a4j:loadScript> usage and sources for the given example.

- Prev6.10. < a4j:loadBundle >
- Top of page
- Front page
- Next6.12. < a4j:loadStyle >