a4j:loadScript is similar to the standard script tag with src attribute, but it allows to load script from alternative sources like a jar file.

src attribute defines the context relative path to the script. Instead of html script tag it's not required to have a prefix of your application. The leading slash in the path means the root of the web context.

You can use "resource://" prefix to access the script file using RichFaces resource framework. For example, if your script file is located inside the jar file and has a full path there: /org/mycompany/assets/script/focus.js , you can point to it with:

Code
<a4j:loadScript src="resource:///org/mycompany/assets/script/focus.js" />

It is possible to register aliases in the static script files or dynamically generated scripts and use those aliases then. For example, RichFaces has an alias for the prototype.js script. So, you can point to "resource://prototype.js" as a src for loading script and use prototype features. The following example shows how to use shipped with RichFaces prototype.js and script.aculo.us to create a client-side effects.

Script demo

Note that if you have an Ajax functionality on a page, the prototype.js is already attached to this page and you do not have to include it explicitly once again.

Since version 3.1.0, RichFaces introduced the rich:effect component. Hence, you do not have to write any javascript to make effects appear in your application.