Insert Javascript code in JSF page

jsf_js
Usually you may need to insert a couple of JavaScript in your JSF page markup.
The following advice helps you do it right:

 <ui:composition ...>
    
    <ui:define name="body">
        
        <!-- your code -->
        
        <h:outputScript target="body">
            <![CDATA[
                alert("It works!");
            ]]>
        </h:outputScript>
        
        <!-- your code -->
        
    </ui:define>
    
</ui:composition>

So, as you see in JSF we use h:outputScript tag with CDATA inside to workaround issues like “The content of elements must consist of well-formed character data or markup” for valid XHTML.

Thanx to http://stackoverflow.com/a/4338816